Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will Redis maxmemory-policy volatile-lru evict if nothing is past expired date?

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?

like image 759
Ray Avatar asked Feb 19 '15 14:02

Ray


People also ask

How does Redis eviction policy?

Eviction policy The default policy for Azure Cache for Redis is volatile-lru , which means that only keys that have a TTL value set with a command like EXPIRE are eligible for eviction. If no keys have a TTL value, then the system won't evict any keys.

What is default eviction policy of Redis?

By default, Amazon ElastiCache for Redis sets the volatile-lru eviction policy for your Redis cluster. When this policy is selected, the least recently used (LRU) keys that have an expiration (TTL) value set are evicted.

How does Redis LRU work?

allkeys-lru helps keep Redis from becoming unresponsive due to insufficient memory and operates on the assumption that you no longer need the least recently used keys. When Redis begins to run out of memory, it samples a small set of keys using an algorithm, then evicts the least recently key from that set.

Does Redis use LRU cache?

The reason Redis does not use a true LRU implementation is because it costs more memory. However, the approximation is virtually equivalent for an application using Redis.


1 Answers

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.

like image 112
Itamar Haber Avatar answered Sep 17 '22 22:09

Itamar Haber