A Cloud Memorystore for Redis instance is running out of memory. The team wants to automatically remove the least recently used keys when memory is full. Which eviction policy should they configure?
Evicts least recently used keys from all keys.
Why this answer
The `allkeys-lru` eviction policy is correct because it applies the LRU (Least Recently Used) algorithm to all keys in the Redis instance, not just those with an expiry set. This ensures that when memory is full, the least recently accessed keys are automatically removed, regardless of whether they have a TTL, which directly meets the requirement to free memory without manual intervention.
Exam trap
A common pitfall is confusing volatile-lru (only keys with TTL) with allkeys-lru (all keys), leading candidates to choose volatile-lru when the requirement is to consider all keys.
How to eliminate wrong answers
Option A is wrong because `volatile-lru` only evicts keys that have an expiry (TTL) set, leaving keys without expiry untouched, which may not free enough memory if the majority of keys are persistent. Option B is wrong because `volatile-ttl` evicts keys with the shortest remaining TTL first, which is not based on access patterns and may remove frequently used keys that happen to have a short TTL. Option C is wrong because `noeviction` prevents any eviction and instead returns errors on write operations when memory is full, which does not automatically remove any keys and can cause application failures.