Search code examples
javaredisspring-data-redis

Spring data redis key expiration


In spring data redis we have two variables.

RedisTemplate<Key, Value> redisTemplate;
HashOperations<Key, HashKey, HashValue> hashOperations;

There is a method expireAt(String key, Date date) inside RedisTemplate. So if I want to set an expiry for a particular hash key I can use this method or this only works at Key level and expires all the entries inside that key?


Solution

  • If it helps anyone, I am using redisTemplate.expireAt(String Key, Date date) method for this purpose. It works for me.