Reading data from a disk-based SQL database like Postgres is relatively slow. To speed up applications, we place an in-memory key-value store like Redis in front of it.
Under the Cache-Aside Pattern:
1. The application checks the cache (Redis) first.
2. Cache Hit: If data is found in Redis, return it immediately (low latency, ~1ms).
3. Cache Miss: If not found, read from Postgres, save it back to Redis for subsequent requests, and then return it.
Let's watch how the simulation engine handles different keys:
john or rohan. Since these are pre-seeded in Redis, the server gets the data instantly and returns, never querying Postgres.doe. Since doe is *not* in Redis but exists in Postgres, the server does a database lookup, gets the record, writes it to Redis, and returns.Interactive Checkpoints
Use these buttons to instantly seed cache memory:
Clear Redis Cache (Force Cache Misses)
LoadClick here to empty all cached pairs in Redis. Running the simulation now will force the Server to query Postgres for every request, showing cache misses.
Pre-seed Redis Cache (Force Cache Hits)
LoadClick here to seed rohan, john, and doe in Redis. Run the simulation to see lightning-fast Cache Hits that never hit Postgres.
No frames available