TomoLink
CompaniesSwiggySystem DesignDesign Distributed Cache
System Design
HardInfrastructure

Design Distributed Cache

50 minscachingdistributed-systemsredis
50 mins
1 sections
caching, distributed-systems

Cache Fundamentals

What is a Cache?

A cache is a high-speed data storage layer that stores a subset of data so that future requests for that data are served faster.

Cache Eviction Policies

  • •LRU (Least Recently Used): Evict the item not used for the longest time
  • •LFU (Least Frequently Used): Evict the item with fewest accesses
  • •FIFO: First in, first out
  • •Random: Evict random items

Cache Write Strategies

  • •Write-through: Write to cache AND DB simultaneously. Consistent but slow writes.
  • •Write-back: Write to cache only; DB updated later. Fast writes but risk of data loss.
  • •Write-around: Write directly to DB, bypass cache. Good for data written once.

Cache Read Strategies

  • •Cache-aside (Lazy Loading): App checks cache → miss → reads DB → updates cache
  • •Read-through: Cache handles DB reads automatically on miss
Design Distributed Cache [Hard] | Swiggy System_design | TomoLink