Jeff Mitchell
Jeff Mitchell

Reputation: 1479

Reclaiming expired keys in Redis

I'm trying to solve the following problem in Redis.

I have a list that contains various available keys:

List MASTER:
111A
222B
333C
444D
555E

I'd like to be able to pop an element off of the list and use it as a key with an expires.

After the expires is up, I'd like to be able to push this number back onto MASTER for future use. I don't see any obvious way to do this, so I'm soliciting for a creative one.

Upvotes: 0

Views: 1323

Answers (1)

Marcel N.
Marcel N.

Reputation: 13986

The best method would be to get called back by Redis when the key expires and then take action. However, callbacks support is still to be added (http://code.google.com/p/redis/issues/detail?id=360). You can either use a Redis version that contains a custom/community modification to support this feature (like the last one in the link I've posted), or worse :): start tracking keys and timeouts in your client app.

Upvotes: 2

Related Questions