Cache-as-SoR (System of Record) Pattern
What you'll learn: How to use a cache as your primary data store instead of just a performance layer.
What Is Cache-as-SoR?
In all the caching patterns you've learned so far (cache-aside, read-through, write-through, write-behind), the cache sits in front of a persistent database, which remains the "source of truth." Cache-as-SoR flips this model: the cache itself becomes the primary data store—the System of Record (SoR)—and persistence to disk becomes optional or secondary.
How It Works
When you write data, it goes directly into the cache (like Redis or Memcached) and stays there. You might:
- Skip persistence entirely (ephemeral data)
- Asynchronously back it up to disk for disaster recovery
- Use the cache's built-in persistence features (Redis RDB/AOF)
Reads always come from cache. There's no "cache miss" fallback to a database because the cache is the database.
When to Use This Pattern
This pattern shines for temporary, fast-changing data that doesn't need long-term storage:
- Session data (user login state, shopping carts)
- Real-time leaderboards (gaming scores)
- Rate limiting counters (API request counts)
- Temporary job queues
Why Choose This Approach?
- Speed: No disk I/O on reads or writes
- Simplicity: One fewer system to manage (no separate database)
- Cost: Cache-only infrastructure can be cheaper for ephemeral data
The Tradeoff
If the cache crashes and you have no backup, all data is lost. That's acceptable for sessions (users just re-login) but catastrophic for financial transactions.
Key Takeaway: Cache-as-SoR treats your cache as the primary data store, perfect for ephemeral or session data where speed matters more than durability.