Redis Eviction Policy
Eviction policy (maxmemory-policy) is the algorithm that Redis uses to free the memory when its actual use in the cluster reaches the maximum available amount of memory (maxmemory).
The maxmemory value is 75% of RAM (the remaining 25% are reserved for service processes).
List of Policies
- volatile-lru — evicts only keys with an expire set using approximated LRU;
- allkeys-lru — evicts any key using approximated LRU;
- volatile-lfu — evicts only keys with an expire set using approximated LFU;
- allkeys-lfu — evicts any key using approximated LFU;
- volatile-random — removes a random key having an expire set;
- allkeys-rando — removes a random key, any key;
- volatile-ttl — removes the key with the nearest expire time (minor TTL);
- noeviction — doesn’t evict anything, just returns an error on write operations.
Change the Eviction Policy
When the policy is changed, the rules for deleting keys also change. We recommend changing the policy only if you know exactly why you need to do it, otherwise you may lose some data.
- From the Control panel, go to the Cloud platform ⟶ Managed Databases section.
- Open the cluster page ⟶ Settings tab.
- In the Eviction policy block, click Edit and select a new algorithm.