An enterprise API uses an Azure Cache for Redis instance to store two distinct categories of data: user session tokens that are assigned a sliding expiration Time to Live (TTL) of 30 minutes, and global application configuration settings that are stored without any TTL. Due to a sudden spike in application usage, the cache memory consumption is approaching its limit. You need to configure a policy that automatically evicts the least recently used session keys under memory pressure, while guaranteeing that all global configuration settings remain in the cache. Which maxmemory-policy configuration should you apply?
- volatile-lruAnswer
- Ballkeys-lru
- Cvolatile-ttl
- Dnoeviction
Answer
volatile-lru
The policy volatile-lru directs Redis to evict keys using the Least Recently Used (LRU) algorithm, but restricts the candidate keys only to those that have an expiration (TTL) set. Because the global configuration settings do not have a TTL, they are excluded from the eviction pool and will remain in the cache, while the session tokens (which do have a TTL) are successfully evicted based on how recently they were used.
Step-by-Step Solution
Key Concept
Azure Cache for Redis maxmemory-policy eviction behaviors and volatile key scoping