Lazy Loading: data is loaded into the cache only on demand when first requested. Subsequent reads are served from the cache. Can result in stale data if the underlying source changes.
Write Through: data is written to the cache at the same time it’s written to the database, ensuring the cache is always up to date.
Session Store: temporary session data is stored in the cache with a TTL to automatically expire after a set period.
“There are only two hard things in Computer Science: cache invalidation and naming things.”
ElastiCache – Redis Use Case: Gaming Leaderboards
Leaderboards require real-time ranking and ordering of scores, which is computationally intensive.
Redis Sorted Sets maintain uniqueness and automatic ordering of elements by score.
Every time a new score is added, it’s ranked instantly and inserted into the correct order, enabling low-latency leaderboard updates.