Reputation: 582
I have a question on Redis cache's behavior. Kindly clarify -
Say, for a key "xyz" if the TTL is set to 15 minutes. And, if its eviction policy in server level is set to "allkeys-lru". Does expired items(cause of TTL) EXPIRE or WAIT until the memory is full?
Upvotes: 9
Views: 12202
Reputation: 49187
The eviction policy only applies to what happens when you exceed the max memory. As long as you're within your memory limits, volatile keys will expire when they should be expired.
Once your memory is full, an LRU algorithm kicks in, evicting least recently used keys. In allkeys-lru
, it doesn't matter whether a key is expired or not and what is the TTL - the least used items will be evicted. In volatile-lru
only expiring keys will be evicted using this algorithm.
Upvotes: 17