Redis

Eviction Policies Interview Questions

How does Redis eviction policy work? — spoken sample answer for Indian interviews.

  • 5Questions with answers
  • 3Difficulty levels

Questions (5)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Intermediate
Question

How does Redis eviction policy work?

Answer:

When Redis hits maxmemory it has to evict or reject writes. The policy is maxmemory-policy. allkeys-lru evicts the least recently used key anywhere. volatile-lru only evicts keys that have a TTL. LFU uses frequency. noeviction means writes start failing. For a pure cache I set allkeys-lru and a maxmemory. For sessions I might use noeviction or I accept that a restart rebuilds from the DB. I always set maxmemory in production. I still put TTLs on cache keys. Eviction is not a substitute for forgetting to expire a key. I would watch evicted_keys on the dashboard.

Question 2
Interview Beginner
Question

noeviction versus allkeys-lru for a cache?

Answer:

A cache should evict. noeviction makes writes fail when full — right for a store, wrong for a cache. Set maxmemory. Unlimited Redis OOMs the host.

Question 3
Interview Intermediate
Question

volatile-lru versus allkeys-lru?

Answer:

volatile only evicts keys with TTL. Mix durable keys without TTL and cache keys with TTL, volatile protects durable. Prefer not to mix in one instance.

Question 4
Interview Intermediate
Question

How do you choose maxmemory?

Answer:

Leave RAM for OS, overhead, peak. Watch used_memory and evicted_keys. I would rather evict than OOM-kill Redis. Not a blog number.

Question 5
Interview Advanced
Question

What happens to a huge sorted set on eviction?

Answer:

The whole key goes, not one member. Huge zsets are dangerous. Cap, shard, or trim. Evicting a big key also spikes latency.

Practice with AI mock interviews

Run Redis mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required