M
M
Michael2016-09-04 02:47:39
Redis
Michael, 2016-09-04 02:47:39

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

1 answer(s)
M
Mark Doe, 2016-09-04
@mak_ufo

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 question

Ask a Question

731 491 924 answers to any question