S
S
sldo_ru2020-08-25 15:30:43
Redis
sldo_ru, 2020-08-25 15:30:43

How to make an expiration on an individual list item in Redis?

I am writing a program on Redis + Nodejs, it is necessary to implement the expiration of list members after some time N. (Added via sadd). How to do it on redis?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shevkalyuk, 2020-08-25
@Enguipro

No way. Expiration can only be set for a key. But you can do the following. Instead of set, use sorted set, and in it, as score, use the timestamp of the time until which the element must exist. Next, just periodically remove all elements with a score value from 0 up to the current time. Well, when reading, make sure that the result does not include elements whose score is already less than the current timestamp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question