1Redis over Memcached
In modern AWS architectures, Redis is almost universally preferred over Memcached due to its High Availability (Multi-AZ), backup capabilities, and advanced data structures.
2Step-by-Step Breakdown
What is Caching?. Caching stores frequently accessed data in RAM, avoiding slow disk-based database queries.
Amazon ElastiCache. A managed service that deploys, operates, and scales open-source in-memory data stores.
Memcached. A simple, pure key-value store. Multi-threaded. No persistence or high availability. Great for basic HTML caching.
Redis. Advanced data structures (lists, sets, hashes). Supports persistence, replication, and Multi-AZ failover.
Knowledge Check. Which ElastiCache engine supports Multi-AZ failover and data persistence?
- →Memcached
- →Redis
Lazy Loading. A caching strategy where the app queries the cache; if data is missing, it queries the DB and writes to the cache.
Write-Through. A strategy where data is written to the cache and the database at the same time. Ensures data is never stale.
Cache Eviction. Caches have limited RAM. Time To Live (TTL) dictates how long data stays before being automatically deleted.
Redis Pub/Sub. Redis isn't just a cache; it supports Publish/Subscribe messaging patterns for real-time applications like chat rooms.
Summary. ElastiCache offloads database pressure and delivers sub-millisecond response times.
