← InfraDraft

Infrastructure Primitives

Design a Distributed Cache (Redis clone)

An in-memory key-value cache cluster with sub-millisecond reads, sharded across nodes with configurable eviction and replication for durability.

Open and Simulate this Architecture in InfraDraft

Core Architectural Components

In-Memory Hash Table Engine

The core O(1) key lookup structure backing every operation.

Sharding / Hash Slot Router

Redis Cluster-style hash-slot assignment routing keys to the owning shard.

Eviction Policy Engine

LRU, LFU, or TTL-based eviction when a shard approaches its memory ceiling.

Replica Set per Shard

Read scaling and automatic failover if a shard primary goes down.

Persistence Layer

RDB snapshotting or AOF logging so cache state survives a restart.

Pub/Sub Messaging Module

Lightweight channel-based messaging layered on the same cluster.

Client-Side Connection Pool & Hashing

Client library that hashes keys locally to route directly to the right shard.