Answer the question
In order to leave comments, you need to log in
Is there any way to configure Redis to delete data after some time?
Hello. I'm using the standard Redis module for Node.js ( https://github.com/NodeRedis/node_redis). The data is stored in hash arrays. Are there any standard methods that allow you to set up automatic deletion of a key if it has not been written to for n minutes?
Ideally, I would also like to hang a handler on this event
Answer the question
In order to leave comments, you need to log in
redis.io/commands/expire
In short - EXPIRE sets a timeout for deletion (after how long the key will be deleted due to the loss of relevance), which is reset when SET is called on this key - because. exactly what you need. There is even an example in the documentation that you give
. For notifications/subscribing to the expired event, you can use, for example , https://www.npmjs.com/package/redis-notifier , its documentation also has an example you need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question