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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With