1

I am storing a Key and value in Redis using redisson java client . Example as below

RMapCache<String, Integer> mapCache = redisson.getMapCache("test");

    // with ttl = 10 seconds
    Integer prevValue = mapCache.put("1", 10, 10, TimeUnit.SECONDS);

Is there a way I can get the remaining ttl for the key when I do a get on the mapCahce ?

Saril Sudhakaran
  • 1,109
  • 9
  • 17

1 Answers1

3

Currently you can do that using RKeys and querying for the keys you are interested in

RKeys rkeys = redissonClient.getKeys();
long ttl = rkeys.remainTimeToLive(key);

It would be nice although to have a wrapper that exposes both the value and the ttl of a key

Xipo
  • 1,765
  • 1
  • 16
  • 23