Skip to main content
InterviewHubPRO
Section Overview
Q12

Question 12 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

24%
Redis & Caching (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are the Redis Memory Eviction Policies (maxmemory-policy)?

senior LevelSystem Design

In Simple Words: When memory usage reaches maxmemory, Redis evicts keys according to the configured policy:

  1. noeviction (Default): Returns out-of-memory errors on new writes (OOM command not allowed).
  2. allkeys-lru: Evicts least recently used keys across all keys (best for general web caches).
  3. volatile-lru: Evicts LRU keys only among keys with an explicit TTL set.
  4. allkeys-lfu: Evicts least frequently used keys (tracks access count; preserves hot keys).
  5. volatile-lfu: Evicts LFU keys among keys with TTL.
  6. volatile-ttl: Evicts keys with the shortest remaining TTL.
  7. allkeys-random / volatile-random: Evicts random keys.