When a Tair (Redis OSS-compatible) instance runs out of memory, the instance triggers an eviction policy to keep memory usage within its configured limit. The default policy depends on the instance type:
volatile-lru: default for Tair DRAM-based instances and Redis Open-Source Edition instances
noeviction: default for Tair persistent memory-optimized instances
Data eviction is not supported for ESSD/SSD-based instances.
Eviction policies
The following table describes all available eviction policies. Policies prefixed with volatile- act only on keys that have a time-to-live (TTL) set; policies prefixed with allkeys- act on all keys regardless of TTL.
| Policy | What it does | When to use it |
|---|---|---|
| volatile-lru *(default for DRAM and Redis Open-Source Edition instances)* | Removes the least recently used (LRU) keys from keys that have a TTL, regardless of whether the keys have expired. | Use when most cached keys have TTLs and you want to keep the most recently accessed data in memory. |
| noeviction *(default for persistent memory-optimized instances)* | Returns errors for write operations when memory is full; no keys are removed. | Use when losing any key is unacceptable and you prefer explicit write errors over silent data loss. |
| volatile-lfu | Removes the least frequently used (LFU) keys from keys that have a TTL. | Use when access frequency is a better indicator of value than recency. |
| volatile-random | Randomly removes keys that have a TTL. | Use when TTL-bearing keys have roughly equal access frequency. |
| volatile-ttl | Removes the TTL-bearing keys with the shortest remaining TTL first. | Use when your application deliberately assigns short TTLs to less important keys. |
| allkeys-lru | Removes the LRU keys across all keys. | Use when a subset of keys is accessed far more often than the rest — a common pattern under the Pareto principle. This is a good general-purpose cache policy. |
| allkeys-lfu | Removes the LFU keys across all keys. | Use when access frequency is a better cache signal than recency. |
| allkeys-random | Randomly removes any key. | Use when all keys are accessed with roughly equal frequency. |
Change the eviction policy
Log on to the Tair console.
On the Parameter Settings page of the target instance, set
maxmemory-policyto the desired policy.
For the full list of configurable parameters, see Configure instance parameters.
FAQ
Why are keys with an expiration time deleted before they expire?
Check whether the instance memory is full. When memory is exhausted, eviction starts immediately. Under the default volatile-lru policy, keys that have a TTL are the first candidates for removal and may be deleted well before they naturally expire. To stop premature eviction, expand the instance memory capacity. For details, see Change the configurations of an instance.
References
If keys disappear but the instance memory is not full, the cause is likely key expiration rather than eviction. For information on how Tair (Redis OSS-compatible) handles expired keys and how to clear them manually, see Clear expired keys in Tair.