Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple redis installation and it seems to slowly eat more and more ram at a steady incline until I restart the redis server.

I'm using redis as a caching layer, currently I don't set an expire on my keys as I didn't think that was necessary. I thought redis would drop off old keys or something - though clearly this isn't happening.

Whats the best way of handling this kind of situation, should I set a short expire time on my keys or is there some functionality built into redis to expire old keys to make room for new ones?

Thanks in advanced!

share|improve this question
Redis isn't memcached, you know. – womble Aug 10 '11 at 23:10

Redis's old tag line is: "A persistent key-value database with built-in net interface written in ANSI-C for Posix systems".

I believe keys are persistent by default. You'll have to set EXPIRE on keys that you actually want to go away after a while. As womble noted, it ain't memcached.

For the command reference:

share|improve this answer
Thanks for your comments :) I think i'll move to something like memcached instead as although redis works great... it wasn't really built for this. – tarnfeld Aug 11 '11 at 6:01

You can set the maxmemory configuration variable in your redis conf and then set the maxmemory-policy to either allkeys-lru or allkeys->random which will allow keys to be removed from the database and make redis act like a cache. Since you're using it as a cache you can comment out all save lines so redis won't save to disk.

This is probably the easiest way and you won't have to switch to memcached, I suggest the allkeys-lru which will allow any key to be removed with the ones that are least recently used being removed first.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.