2

I am trying to implement an RLocalCachedMap in my app. While experimenting I was creating a LocalCachedMap and was setting an evictionPolicy and TTL in the LocalCachedMapOptions. I was expecting that any entry added to the map would expire after the max TTL had passed, but I learned that was not the case. I later learned that such functionality is only available in RedissonPRO which I am not using.

Now I am wondering, if setting the EvictionPolicy and TTL in the LocalCachedMapOptions will actually do anything at all? Does the entry have an expiration time on the Redis server? If so, can I configure Redis to clear out expired entries since Redisson seems to ignore the TTL?

Is there any way to use the RLocalCachedMap and have entries expire after a certain amount of time?

Garct
  • 31
  • 3

1 Answers1

2

EvictionPolicy and TimeToLive are applied to RLocalCachedMap instance if they defined.

if setting the EvictionPolicy and TTL in the LocalCachedMapOptions will actually do anything at all? Does the entry have an expiration time on the Redis server?

Only entry stored in local cache get this ttl and not entry stored in Redis.

If so, can I configure Redis to clear out expired entries since Redisson seems to ignore the TTL?

to apply ttl for Redis you need to use RLocalCachedMapCache (part of Redisson PRO) or RMapCache object (without local cache)

Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71
  • TTL does not seem to work locally either. – Panu Haaramo Jan 04 '23 at 14:08
  • Tried also with `RMapCache cache = redissonClient.getMapCache(CACHE_NAME, options);`. Same result, entries seem to stay forever in the map even though I've set `timeToLive` to 1 sec in options. – Panu Haaramo Jan 04 '23 at 14:38
  • Can you open the issue on github with code example to reproduce it? – Nikita Koksharov Jan 05 '23 at 08:22
  • We are using the free open source version. I noticed that according to this TTL does not work with that (`getLocalCachedMap()`) : https://github.com/redisson/redisson/wiki/7.-distributed-collections#71-map We'd like to use the local map for performance. – Panu Haaramo Jan 05 '23 at 09:24
  • Or should I use `RLocalCachedMap#getCachedMap`? Based on Javadoc I don't understand how it differs from calling `RLocalCachedMap` directly. – Panu Haaramo Jan 05 '23 at 10:24
  • Based on my testing using `RLocalCachedMap#getCachedMap` makes TTL work. – Panu Haaramo Jan 05 '23 at 10:40