use of org.redisson.cache.LocalCachedMapEnable in project redisson by redisson.
the class RedissonTransaction method enableLocalCache.
private void enableLocalCache(String requestId, Map<HashKey, HashValue> hashes) {
if (hashes.isEmpty()) {
return;
}
RedissonBatch publishBatch = createBatch();
for (Entry<HashKey, HashValue> entry : hashes.entrySet()) {
String name = RedissonObject.suffixName(entry.getKey().getName(), RedissonLocalCachedMap.TOPIC_SUFFIX);
RTopicAsync topic = publishBatch.getTopic(name, LocalCachedMessageCodec.INSTANCE);
LocalCachedMapEnable msg = new LocalCachedMapEnable(requestId, entry.getValue().getKeyIds().toArray(new byte[entry.getValue().getKeyIds().size()][]));
topic.publishAsync(msg);
}
try {
publishBatch.execute();
} catch (Exception e) {
// skip it. Disabled local cache entries are enabled once reach timeout.
}
}
use of org.redisson.cache.LocalCachedMapEnable in project redisson by redisson.
the class RedissonTransaction method enableLocalCacheAsync.
private RFuture<BatchResult<?>> enableLocalCacheAsync(String requestId, Map<HashKey, HashValue> hashes) {
if (hashes.isEmpty()) {
return RedissonPromise.newSucceededFuture(null);
}
RedissonBatch publishBatch = createBatch();
for (Entry<HashKey, HashValue> entry : hashes.entrySet()) {
String name = RedissonObject.suffixName(entry.getKey().getName(), RedissonLocalCachedMap.TOPIC_SUFFIX);
RTopicAsync topic = publishBatch.getTopic(name, LocalCachedMessageCodec.INSTANCE);
LocalCachedMapEnable msg = new LocalCachedMapEnable(requestId, entry.getValue().getKeyIds().toArray(new byte[entry.getValue().getKeyIds().size()][]));
topic.publishAsync(msg);
}
return publishBatch.executeAsync();
}
Aggregations