【fix sonar】JeroRedisCacheWriter文件
This commit is contained in:
+7
-7
@@ -48,7 +48,7 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
this.execute(name, (connection) -> {
|
this.execute(name, connection -> {
|
||||||
if (shouldExpireWithin(ttl)) {
|
if (shouldExpireWithin(ttl)) {
|
||||||
connection.set(key, value, Expiration.from(ttl.toMillis(), TimeUnit.MILLISECONDS), SetOption.upsert());
|
connection.set(key, value, Expiration.from(ttl.toMillis(), TimeUnit.MILLISECONDS), SetOption.upsert());
|
||||||
} else {
|
} else {
|
||||||
@@ -63,7 +63,7 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
public byte[] get(String name, byte[] key) {
|
public byte[] get(String name, byte[] key) {
|
||||||
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
||||||
return this.execute(name, (connection) -> connection.get(key));
|
return this.execute(name, connection -> connection.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,7 +71,7 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
Assert.notNull(key, KEY_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
return this.execute(name, (connection) -> {
|
return this.execute(name, connection -> {
|
||||||
if (this.isLockingCacheWriter()) {
|
if (this.isLockingCacheWriter()) {
|
||||||
this.doLock(name, connection);
|
this.doLock(name, connection);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
return delNum;
|
return delNum;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
this.execute(name, (connection) -> connection.del(new byte[][]{key}));
|
this.execute(name, connection -> connection.del(new byte[][]{key}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
public void clean(String name, byte[] pattern) {
|
public void clean(String name, byte[] pattern) {
|
||||||
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
Assert.notNull(name, NAME_MUST_NOT_BE_NULL);
|
||||||
Assert.notNull(pattern, "Pattern must not be null!");
|
Assert.notNull(pattern, "Pattern must not be null!");
|
||||||
this.execute(name, (connection) -> {
|
this.execute(name, connection -> {
|
||||||
boolean wasLocked = false;
|
boolean wasLocked = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -151,11 +151,11 @@ public class JeroRedisCacheWriter implements RedisCacheWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lock(String name) {
|
void lock(String name) {
|
||||||
this.execute(name, (connection) -> this.doLock(name, connection));
|
this.execute(name, connection -> this.doLock(name, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock(String name) {
|
void unlock(String name) {
|
||||||
this.executeLockFree((connection) -> this.doUnlock(name, connection));
|
this.executeLockFree(connection -> this.doUnlock(name, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean doLock(String name, RedisConnection connection) {
|
private Boolean doLock(String name, RedisConnection connection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user