A gaming company uses an Azure Cache for Redis instance to store real-time leaderboard statistics and user session states. The leaderboard keys must persist indefinitely and are not configured with a Time-to-Live (TTL). The user session keys are configured with a sliding TTL. During peak gaming events, the cache reaches its memory limit, causing write operations to fail. You need to configure the cache to automatically evict the user session keys that are accessed the least frequently to free up memory, while ensuring that the leaderboard keys are never evicted. Which eviction policy should you configure to meet these requirements?
- volatile-lfuAnswer
- Ballkeys-lfu
- Cvolatile-lru
- Dnoeviction
Answer
volatile-lfu
The volatile-lfu policy evicts the least frequently used keys among those that have an expiration (TTL) set. Because only the user session keys have a TTL configured, and the leaderboard keys do not, this policy guarantees that leaderboard keys are preserved. Additionally, it uses the Least Frequently Used (LFU) algorithm, satisfying the requirement to evict keys based on access frequency.
Step-by-Step Solution
Key Concept
Selecting the correct Redis eviction policy based on TTL configuration and access patterns to prevent data loss of critical keys.