The stale entry#
Release 2026.11.3 caches users under user:{id} and deletes that key after changing a user. Release 2026.11.4 caches under user:v2:{id}, as change a cached object's format during a rolling deploy recommends. Both run during the rollout. We ran this against Redis 7.0.15 from Python 3.11:
def old_update_phone(user_id, phone): # 2026.11.3
db_update_phone(user_id, phone)
redis.delete(f"user:{user_id}")
Both releases had read user 42, so both keys held +49 30 1234. Then an old-release pod saved a new number:
old_update_phone(42, "+49 30 9999")
| Reader | Phone shown | Entry's remaining lifetime |
|---|---|---|
2026.11.3 | +49 30 9999 | rebuilt |
2026.11.4 | +49 30 1234 | 3,600 s |
The user changed their number on one request and saw the old one on the next, whenever the load balancer sent them to a new-release pod. Nothing failed, and the cache's hit rate looked healthy.
Delete both keys first#
The old release cannot learn a key name after it has shipped, so the fix has to be in place before the new key exists:
Ship a release that still reads and writes
user:{id}, and deletes bothuser:{id}anduser:v2:{id}on every write:redis.delete(f"user:{user_id}", f"user:v2:{user_id}")Deleting a key that does not exist costs one round trip and does nothing else.
When that release is the oldest one that can run, including as the rollback target, ship the release that reads
user:v2:{id}. It deletes both keys too.
Every write by either release now removes both entries. A rollback to step 1's release keeps the new entries current as well, so rolling forward again does not serve stale data.
If step 1 is too late#
When the new key is already in use and the old release cannot be changed, shorten the new entry's lifetime for the rollout, for example to a minute, so a stale entry ends quickly. The cost is a lower hit rate. Restore the normal lifetime when the old release is gone. Another way out is a cache that both releases can invalidate through a shared signal, such as a per-user version number stored in the database, but that also has to ship in the old release first.
The compatibility test#
With both releases on one Redis in staging, cache a user from each, change the user through each release, and read from the other. Pass when every read after a change shows the new value. The general sequence for data in two shapes is in moving data while two application releases share one database.