Consider a Redis cache where keys are set without expiration time. What is the likely outcome after continuous data updates?
SET user:123 "John Doe" # No expiration set
Think about what happens if keys never expire and new data keeps adding.
Without expiration, cached keys remain forever, causing memory to fill up over time.
Which benefit best explains why the cache aside pattern is used in caching?
Think about who controls the cache loading in cache aside.
Cache aside lets the application decide when to load or refresh cache, helping keep data fresh.
Choose the Redis command that sets a key "session:1" with value "active" and expires after 60 seconds.
Look for the command that combines setting and expiration in one.
SETEX sets a key with a value and expiration time in seconds in one command.
When many clients request the same missing cache key simultaneously, what is a good strategy to prevent all from querying the database at once?
Think about controlling who loads data when cache is missing.
Using a lock ensures only one client loads data, preventing many database hits at once.
Given this sequence:
1. Cache key "product:10" set with old data.
2. Database updated with new product info.
3. Cache key deleted.
4. Application reads cache key "product:10" expecting new data.
Why might the application still see old data?
Consider timing between cache deletion and database update.
If cache deletion and database update are separate steps, another read may re-cache old data before update completes.