Redis & Caching (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Redis Memory Eviction Policies: LRU vs LFU.
senior LevelredisAdvanced Internals
In Simple Words:
When memory reaches maxmemory, Redis evicts keys according to its configured policy:
noeviction(Default): Returns errors on write operations when memory is full.allkeys-lru: Evicts the Least Recently Used keys across all keys (best for general caching).allkeys-lfu: Evicts the Least Frequently Used keys based on access count counters (prevents a burst of temporary keys from evicting permanent hot keys).volatile-ttl: Evicts keys with the shortest remaining TTL among keys set with expirations.