How a cache decides what to throw out (LRU/LFU/TTL) and how writes propagate to the backing store (through/back/around).
Plain English: a cache has limited room, so it needs rules for what to evict when full (usually 'kick out whatever was used least recently') and rules for how writes reach the real database (write to both at once, write to cache and flush later, or skip the cache on writes). These choices decide your speed-vs-correctness tradeoff.
Two related sets of policies. Eviction policies decide which entries to drop when the cache is full or stale: LRU (least recently used), LFU (least frequently used), FIFO, and TTL-based expiry. Write policies decide how a write flows between cache and the source of truth: write-through (both synchronously), write-back/write-behind (cache now, DB async), and write-around (DB only, skip the cache).
A cache has finite memory, so something must be evicted when it fills. Pick wrong and you evict the hot data you needed. And on writes you must decide whether the cache and database stay in lockstep (safe, slower) or diverge temporarily (fast, riskier). These policies are the knobs that set your cache's hit rate, write latency, and staleness window.
Eviction: LRU tracks recency and drops the coldest entry (good general default, the most common); LFU tracks access counts and keeps the popular ones (better for skewed access but slower to adapt); TTL expires entries after a fixed time regardless of use (the simplest defense against staleness). Writes: write-through updates cache and DB synchronously (consistent, slower writes); write-back updates the cache and flushes to the DB asynchronously (fast writes, risk of data loss if the cache dies before flush); write-around writes straight to the DB and lets the cache populate lazily on the next read (avoids polluting the cache with write-once data).
Per-node eviction (LRU/LFU) plus TTLs decide what each ring node keeps; write policy sets whether it's a look-aside or write-through cache
Cache-aside reads with write-around: new short links are written to Postgres and populate Redis lazily on first redirect
Precomputed timelines in Redis carry TTLs and LRU eviction so cold users' feeds get reclaimed for active ones