How to “EXPIRE” the “HSET” child key in redis?

前端 未结 11 2070
予麋鹿
予麋鹿 2020-11-30 21:10

I need to expire all keys in redis hash, which are older than 1 month.

11条回答
  •  囚心锁ツ
    2020-11-30 21:23

    There is a Redisson java framework which implements hash Map object with entry TTL support. It uses hmap and zset Redis objects under the hood. Usage example:

    RMapCache map = redisson.getMapCache('map');
    map.put(1, 30, TimeUnit.DAYS); // this entry expires in 30 days
    

    This approach is quite useful.

提交回复
热议问题