policy or algorithm that determines which item(s) to remove from a cache when it reaches its maximum
capacity. It’s a crucial aspect of cache management to maintain efficiency and performance.
| Policy | Description | Typical Use |
|---|---|---|
| LRU (Least Recently Used) | Removes least recently used item | General-purpose caching |
| LFU (Least Frequently Used) | Removes least accessed item | Skewed traffic where few items dominate |
| FIFO (First In First Out) | Removes oldest inserted item | Simple caches |
| Random | Removes a random item | High-throughput caches like Redis |
| Time-based Expiry | Removes items after TTL expires | CDN, session storage |
LRU Least Recently Used
LRU stands for Least Recently Used, which is a popular cache eviction policy used in computing. When a cache reaches its size limit and needs to make space for new items, LRU removes the item that has not been accessed or used for the longest time—i.e., the “least recently used” item is evicted.LRU implementation
LFU Least Frequently Used
Evict the key with the lowest access frequency. Ties can be broken by recency or arbitrary order.LFU
FIFO First in last out
Evict the oldest entry—i.e., the one that was inserted earliest.LFU