{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreibwuv2kfncvdjuouoxrqsm5g2xxmucwhx2ibeksn2qmd5ufduds7i",
"uri": "at://did:plc:5sgu76a53rz3n6unbykmovqy/app.bsky.feed.post/3mlofbvmaqkx2"
},
"description": "An eviction policy is the rule a cache uses to decide which entry to remove when it reaches its memory limit and needs to make room for a new entry. Choice of policy directly affects hit rate and is one of the most consequential cache configuration decisions.\n\n\nCommon policies\n\n * LRU (Least Recently Used). Evict the entry that has not been accessed for the longest time. Default in many systems; good for workloads with recent-bias.\n * LFU (Least Frequently Used). Evict the entry with the lowest ",
"path": "/engineering-glossary/eviction-policy-cache-replacement/",
"publishedAt": "2026-05-12T18:12:42.000Z",
"site": "https://sahilkapoor.com",
"tags": [
"Caching",
"Redis",
"Memcached",
"TTL"
],
"textContent": "**An eviction policy** is the rule a cache uses to decide which entry to remove when it reaches its memory limit and needs to make room for a new entry. Choice of policy directly affects hit rate and is one of the most consequential cache configuration decisions.\n\n## Common policies\n\n * **LRU (Least Recently Used).** Evict the entry that has not been accessed for the longest time. Default in many systems; good for workloads with recent-bias.\n * **LFU (Least Frequently Used).** Evict the entry with the lowest access count. Better for workloads where some items are hot regardless of recency.\n * **FIFO (First In, First Out).** Evict the oldest entry by insertion time. Simple, ignores access patterns.\n * **Random.** Evict a random entry. Cheap and surprisingly competitive on some workloads.\n * **TLRU (Time-aware LRU).** LRU with TTL awareness; expired entries are preferred for eviction.\n * **ARC (Adaptive Replacement Cache).** Dynamically balances recency and frequency.\n * **TinyLFU and W-TinyLFU.** Modern, used by Caffeine; uses a frequency sketch to decide admission.\n\n\n\n## Variants in Redis\n\nRedis exposes the policy via `maxmemory-policy`: `noeviction`, `allkeys-lru`, `allkeys-lfu`, `allkeys-random`, `volatile-lru`, `volatile-lfu`, `volatile-random`, `volatile-ttl`. The `volatile-*` variants only evict entries that have a TTL set.\n\nš\n\n**Related Terms**\nCaching, Redis, Memcached, TTL.",
"title": "Eviction Policy",
"updatedAt": "2026-05-13T19:15:01.531Z"
}