Thanks for authoring and maintaining this great project.
We are considering moving over to Redisson to make use of it's local cache feature as it provides a performance boost comparing directly retrieving data from redis. Run into this when trying to clear local cache, seems like the cache was not cleared, everything stills stays. Is this the expected behavior, what would be the best to way to clear all caches, could you shed more lights on this please?
Clears local cache across all instances
https://static.javadoc.io/org.redisson/redisson/3.6.4/org/redisson/api/RLocalCachedMap.html#clearLocalCacheAsync--
Local cache is not cleared, everything in local cache persists
import org.redisson.Redisson;
import org.redisson.api.LocalCachedMapOptions;
import org.redisson.api.RLocalCachedMap;
import org.redisson.api.RedissonClient;
public class RedissonLocalCache {
private final RLocalCachedMap<String, String> localMap;
private static RedissonClient client = Redisson.create();
public RedissonLocalCache() {
localMap = client.getLocalCachedMap(
"myMapName",
LocalCachedMapOptions.defaults()
);
}
public void clearTest() {
localMap.fastPut("key", "value");
localMap.clearLocalCache();
System.out.println("map size after clear: " + localMap.keySet().size());
}
}
To run:
RedissonLocalCache test = new RedissonLocalCache();
test.clearTest();
4.0.8
3.8.2
default
localMap.keySet().size() outputs size of data stored in Redis and not in local cache
Thanks for the reply. So clearLocalCache() will only clear caches stored in local map, while get() will get data from local cache and Redis.
Is there is a way to invalidate all caches in local cache as well as corresponding caches in Redis, or even better, does Redisson provide some sort of distributed syncing on local cache with pubsub/listenpush please?
Did more testing on this, seems like clearLocalCache() only works on local cache, but clear() does the clear for both local cache and Redis, is this the expected behavior, maybe clear() is the way to go if "complete" invalidation is desired?
does Redisson provide some sort of distributed syncing on local cache with pubsub/listenpush please?
Use SyncStrategy.UPDATE to achieve that.
but clear() does the clear for both local cache and Redis, is this the expected behavior, maybe clear() is the way to go if "complete" invalidation is desired?
You can clear data located at both local cache and redis by "delete" or "clear" methods
Most helpful comment
Use SyncStrategy.UPDATE to achieve that.
You can clear data located at both local cache and redis by "delete" or "clear" methods