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

前端 未结 11 2041
予麋鹿
予麋鹿 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:24

    This is possible in KeyDB which is a Fork of Redis. Because it's a Fork its fully compatible with Redis and works as a drop in replacement.

    Just use the EXPIREMEMBER command. It works with sets, hashes, and sorted sets.

    EXPIREMEMBER keyname subkey [time]

    You can also use TTL and PTTL to see the expiration

    TTL keyname subkey

    More documentation is available here: https://docs.keydb.dev/docs/commands/#expiremember

提交回复
热议问题