Multiple ChoiceHard 45s
Cache invalidation on write
When updating a DB row with a cached entry, why is 'delete the cache key' usually preferred over 'update the cache key'?
Options
- 1Deleting the cache key is strictly faster than updating it in place, so the choice is made purely for latency and not for any correctness reason
- 2Concurrent updates can interleave such that an older value overwrites a newer one in the cache; deleting avoids storing a stale value, letting the next read repopulate
- 3Updating the cache key directly violates the TTL contract of the entry, so deletion is required to keep the expiration timers consistent with the store
- 4Deleting the cache key bypasses the database entirely, so the value stays absent from the cache until some manual repopulation job eventually runs again
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.