sys-d
// distributed systems lab
Fixed Window CounterSliding Window LogSliding Window CounterToken BucketLeaky Bucket
Circuit BreakerRetry with BackoffTimeout WrapperBulkheadHedged RequestsFallback Strategy
LRU CacheLFU CacheTTL CacheCache AsideWrite-Through/BackCache StampedeBloom Filter
Round RobinWeighted Round RobinLeast ConnectionsIP HashingConsistent Hashing
In-Memory QueuePub/Sub BrokerAt-Most-OnceAt-Least-OnceDead Letter QueueConsumer GroupsPartitioned Log
Distributed LockLeader ElectionHeartbeat MonitorService RegistryService Discovery
Primary-ReplicaRead/Write QuorumVector ClocksCRDT Counters
Two Phase CommitThree Phase CommitSimplified Raft
Key-Value StoreAppend-Only LogWrite Ahead LogSSTableLSM Tree
Metrics CollectorHistogramStructured LoggerTrace ID Propagation
JWT ValidationAPI Key ValidationIdempotency KeyHMAC Verification
v1.0 · MIT
caching

Caching Patterns

Strategies for storing frequently accessed data closer to the consumer, reducing latency and backend load.

// concept

Caching stores copies of data in fast-access storage layers. The challenge lies in choosing what to cache, when to evict, and how to keep cached data consistent with the source of truth.

LRU Cache

Evict the least recently used item when capacity is reached. O(1) get/put with a hash map + doubly linked list.

LFU Cache

Evict the least frequently used item. Tracks access counts to keep the hottest data in memory.

TTL Cache

Entries expire after a time-to-live. Ensures stale data is automatically purged without manual invalidation.

Cache Aside

Application checks cache first, loads from DB on miss, then populates cache. Most common caching strategy.

Write-Through/Back

Write-through writes to cache and DB synchronously. Write-back buffers writes for eventual persistence.

Cache Stampede

Prevent thundering herd when a popular key expires. Use locking or probabilistic early expiration.

Bloom Filter

Space-efficient probabilistic structure to test set membership. May have false positives but never false negatives.