All Products
Search
Document Center

ApsaraDB for Redis:What is the default eviction policy of ApsaraDB for Redis?

Last Updated:Apr 22, 2024

If an instance of ApsaraDB for Redis is out of memory, a data eviction (or removal) policy is triggered to ensure that the instance does not exceed its memory limit. The default policy is volatile-lru. This policy evicts the less recently used (LRU) keys from keys that have a time-to-live (TTL) configured. This topic describes the eviction policies of ApsaraDB for Redis.

Modify the eviction policy of an instance

To modify the eviction policy of an instance, log on to the ApsaraDB for Redis console, click the instance ID on the Instances page to go to the Instance Information page, and then click Parameter Settings in the left-side navigation pane. For more information, see Configure instance parameters.

Available eviction policies

  • volatile-lru (default): evicts the LRU keys from keys that have a TTL configured regardless of whether the keys have expired.

  • volatile-lfu: evicts the LFU keys from keys that have a TTL configured.

  • volatile-random: randomly evicts keys from keys that have a TTL configured.

  • volatile-ttl: evicts the keys that have the shortest TTL from keys that have a TTL configured.

  • allkeys-lru: evicts the LRU keys from all keys.

  • allkeys-lfu: evicts the LFU keys from all keys.

  • allkeys-random: randomly evicts keys from all keys.

  • noeviction: does not evict keys to make space when the memory limit is reached, but returns errors for write operations.

References

If the number of keys decreases, data may be deleted due to expiration. For information about the policies for deleting expired keys and methods to manually delete expired keys in ApsaraDB for Redis, see How do I delete expired keys in ApsaraDB for Redis?