Skip to main content

Redis Eviction Policies

An eviction policy is a rule by which Redis evicts keys to free up memory when memory consumption reaches the set limit. Read more about eviction policies in the Key eviction documentation in the Redis docs.

You can view the list of eviction policies.

You can select an eviction policy when creating a cluster or change it in an existing cluster.

Memory limit for key storage

The memory limit for storing keys is set in the maxmemory parameter. The default maxmemory value is 75% of the RAM on a cluster node. The remaining 25% is mandatory reserved for Redis system mechanisms.

You can change the maxmemory value only in Redis version 8:

You can change the value in the range from 1% to 75%. If you specify a value less than 75%, the remaining memory can be used by Redis system mechanisms.

List of eviction policies

noeviction

It does not evict keys when the limit specified in maxmemory is reached. New write operations will fail due to out-of-memory errors

volatile-lru

It evicts keys with a set time-to-live (TTL) that have not been accessed for a long time. Keys are evicted using an approximated LRU algorithm

volatile-lfu

It evicts keys with a TTL that have been accessed the least frequently since the TTL was set. Keys are evicted using an approximated LFU algorithm

volatile-ttlEvicts keys with the shortest remaining TTL
volatile-randomEvicts random keys with TTL
allkeys-lru

It evicts any keys that have not been accessed for a long time. Keys are evicted using an approximated LRU algorithm

allkeys-lfu

It evicts any keys that have been accessed the least frequently since they were created. Keys are evicted using an approximated LFU algorithm

allkeys-randomEvicts any random keys

Change the Eviction policy

For your information

We recommend changing the policy only if you are sure about the consequences — there is a possibility of partial data loss.

  1. In the Dashboard, on the top menu, click Products and select Managed Databases.
  2. In the Databases section, open the Active tab.
  3. Open the cluster page → Settings tab.
  4. In the Eviction Policy block, click Change.
  5. In the Maxmemory Policy field, select an eviction policy.
  6. Click Save.