Caching medium
Redis is often chosen over Memcached for modern systems. Which architectural difference is a key reason?
- A Memcached is single-threaded, causing blocking on large values.
- B Redis supports complex data types (Hashes, Sets, Sorted Sets) server-side, allowing efficient partial updates and operations without shipping full objects.
- C Memcached has no eviction policy.
- D Redis is strictly faster for simple string Get/Set operations.
Answer: B. Redis supports complex data types (Hashes, Sets, Sorted Sets) server-side, allowing efficient partial updates and operations without shipping full objects.
Redis improves upon Memcached by offering **rich server-side data structures** (Lists, Sets, Sorted Sets, Hashes). In Memcached, appending to a list requires fetching the whole object, modifying it in code, and uploading it back (Race Condition prone + High Bandwidth). In Redis, `RPUSH key value` is an atomic, low-bandwidth server-side operation.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In the Cache-Aside pattern, what happens when the application requests data that is missing from the cache (a 'Cache Miss')?
- Why use a centralized Distributed Cache (like a Redis Cluster) over local in-memory caches on each web server?
- Setting a short TTL (e.g., 60 seconds) on a cached object helps to:
- What is the primary architectural goal of introducing a cache into a system?
- Most caching systems rely on the principle of 'Temporal Locality', which states:
- Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?