6

I've a redis server set with a maxmemory-policy set to volatile-lru. The documentation indicate this will evict from the set of entries with expires set when memory limit has reached.

In this case, does redis only evict items past their expiration? If everything in memory has an expire set, but nothing is past the expiration time, will anything get evicted when max memory is reached?

1 Answer 1

8

If your eviction policy is set to any of the volatile-* policies, when running out of memory and having no volatile keys to evict, Redis will return an OOM error.

6
  • 1
    Thanks. Just to clarify: If all volatile keys have expires that are in the future, does that mean there are no evictable volatile keys? i.e. Can only a key past it's expire be considered for eviction?
    – Ray
    Feb 19, 2015 at 14:56
  • 1
    No - once a key is set with a TTL, it is considered volatile (and will be a candidate for eviction under the volatile-* policies). When a volatile key expires it can no longer be evicted as it no longer exists. Feb 19, 2015 at 14:59
  • Ok, so if all my keys have expires in the future (are volitile), when memory max is reached it should still start evicting the oldest ones if volitile LRU is set.
    – Ray
    Feb 19, 2015 at 15:19
  • Please state what happens if a TTL is explicitly set to -1? In my experience, keys set like this are not eligible for volatile-* evictions.
    – keithl8041
    Dec 14, 2017 at 12:29
  • @keithl8041I'm not aware of a way to directly set a key's TTL to any value, it is controlled indirectly by the EXPIRE/PEXPIRE/SET .. EX commands and providing a negative value causes immediate expiration. Dec 15, 2017 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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