Java源码示例:org.redisson.api.RKeys
示例1
@Override
public void clear() {
long start = SystemTimer.currTime;
RKeys keys = redisson.getKeys();
// keys.deleteByPattern(keyPrefix(cacheName) + "*");
keys.deleteByPatternAsync(keyPrefix(cacheName) + "*");
long end = SystemTimer.currTime;
long iv = end - start;
log.info("clear cache {}, cost {}ms", cacheName, iv);
}
示例2
@Override
public void commit(CommandAsyncExecutor commandExecutor) {
RKeys keys = new RedissonKeys(commandExecutor);
keys.unlinkAsync(getName());
if (lockName != null) {
RedissonLock lock = new RedissonLock(commandExecutor, lockName);
lock.unlockAsync();
}
}
示例3
@Override
public void commit(CommandAsyncExecutor commandExecutor) {
RKeys keys = new RedissonKeys(commandExecutor);
keys.deleteAsync(getName());
if (lockName != null) {
RedissonLock lock = new RedissonTransactionalLock(commandExecutor, lockName, transactionId);
lock.unlockAsync();
}
}
示例4
@Override
public void commit(CommandAsyncExecutor commandExecutor) {
RKeys keys = new RedissonKeys(commandExecutor);
keys.touchAsync(getName());
RedissonLock lock = new RedissonLock(commandExecutor, lockName);
lock.unlockAsync();
}
示例5
@BeforeEach
public void beforeTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例6
@AfterEach
public void afterTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例7
@After
public void teardown() {
// Clear the database
RKeys keys = client.getKeys();
keys.flushdb();
}
示例8
@Before
public void beforeTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例9
@After
public void afterTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例10
@Before
public void beforeTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例11
@After
public void afterTest() {
RKeys keys = redisson.getKeys();
keys.flushdb();
}
示例12
public TracingRKeys(RKeys keys, TracingRedissonHelper tracingRedissonHelper) {
this.keys = keys;
this.tracingRedissonHelper = tracingRedissonHelper;
}
示例13
@Override
public RKeys getKeys() {
return new TracingRKeys(redissonClient.getKeys(), tracingRedissonHelper);
}
示例14
@Override
public RFuture<Boolean> trySetAsync(Map<String, ?> buckets) {
checkState();
RPromise<Boolean> result = new RedissonPromise<>();
executeLocked(result, () -> {
Set<String> keysToSet = new HashSet<>();
for (String key : buckets.keySet()) {
Object value = state.get(key);
if (value != null) {
if (value != NULL) {
operations.add(new BucketsTrySetOperation(codec, (Map<String, Object>) buckets, transactionId));
result.trySuccess(false);
return;
}
} else {
keysToSet.add(key);
}
}
if (keysToSet.isEmpty()) {
operations.add(new BucketsTrySetOperation(codec, (Map<String, Object>) buckets, transactionId));
state.putAll(buckets);
result.trySuccess(true);
return;
}
RKeys keys = new RedissonKeys(commandExecutor);
String[] ks = keysToSet.toArray(new String[keysToSet.size()]);
keys.countExistsAsync(ks).onComplete((res, e) -> {
if (e != null) {
result.tryFailure(e);
return;
}
operations.add(new BucketsTrySetOperation(codec, (Map<String, Object>) buckets, transactionId));
if (res == 0) {
state.putAll(buckets);
result.trySuccess(true);
} else {
result.trySuccess(false);
}
});
}, buckets.keySet());
return result;
}
示例15
private void deleteByPattern(final String pattern) {
final RKeys keySet = client.getKeys();
keySet.getKeysByPattern(pattern).forEach(k -> keySet.delete(k));
}