|
|
|
@ -170,6 +170,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonExpirable implements R
|
|
|
|
|
private RMap<K, V> map;
|
|
|
|
|
private Cache<CacheKey, CacheValue> cache;
|
|
|
|
|
private int invalidateEntryOnChange;
|
|
|
|
|
private int invalidationListenerId;
|
|
|
|
|
|
|
|
|
|
protected RedissonLocalCachedMap(RedissonClient redisson, CommandAsyncExecutor commandExecutor, String name, LocalCachedMapOptions options) {
|
|
|
|
|
super(commandExecutor, name);
|
|
|
|
@ -198,7 +199,8 @@ public class RedissonLocalCachedMap<K, V> extends RedissonExpirable implements R
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invalidationTopic = redisson.getTopic(name + ":topic");
|
|
|
|
|
invalidationTopic.addListener(new MessageListener<Object>() {
|
|
|
|
|
if (options.isInvalidateEntryOnChange()) {
|
|
|
|
|
invalidationListenerId = invalidationTopic.addListener(new MessageListener<Object>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onMessage(String channel, Object msg) {
|
|
|
|
|
if (msg instanceof LocalCachedMapClear) {
|
|
|
|
@ -211,6 +213,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonExpirable implements R
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int size() {
|
|
|
|
@ -360,6 +363,13 @@ public class RedissonLocalCachedMap<K, V> extends RedissonExpirable implements R
|
|
|
|
|
encodedKey, encodedValue, msg, invalidateEntryOnChange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void destroy() {
|
|
|
|
|
if (invalidationListenerId != 0) {
|
|
|
|
|
invalidationTopic.removeListener(invalidationListenerId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public V remove(Object key) {
|
|
|
|
|
return get(removeAsync((K)key));
|
|
|
|
|