Solution skill
Cache-aside with invalidation on Upstash Redis: the writer owns its keys
Complete solution
Cache-aside with explicit invalidation: the writer owns the keys it dirties, and key names encode what invalidates them. Not for different error messages.
TL;DR: Cache-aside with explicit invalidation: the writer owns the keys it dirties, and key names encode what invalidates them. Cache-aside with invalidation on Upstash Redis Read path 1. Write path: the writer invalidates Whoever changes the source of truth deletes the affected cache keys in the same code path.
The fix
Cache-aside with invalidation on Upstash Redis
Read path
- GET product:123.
- Hit: return it.
Miss: load from the source of truth, SET it with a TTL, return it.
The TTL is your backstop. Even if invalidation has a bug, stale data dies on schedule.
Write path: the writer invalidates
Whoever changes the source of truth deletes the affected cache keys in the same code path. Not a separate cron, not eventually: the same function that writes the database issues the DEL.
For a product update:
DEL product:123 DEL category:shoes:list
Key naming that makes invalidation possible
Name keys by what invalidates them. product:123 is invalidated by product 123 changing. A key like homepage:v7:2026-09-26 cannot be invalidated surgically: you would need to know every date variant. Prefer entity keys over rendered-page keys.
Stampede protection
On a miss storm (cache cold, traffic spike), many requests miss at once and hammer the origin. Mitigations:
SET NX a lock key with a short TTL; only the lock holder loads from origin, the rest wait briefly and retry the GET.
Stagger TTLs with jitter so keys do not expire in the same second.
Verify
Update an entity, then GET its cache key - it should miss once, then repopulate with fresh data. Load-test a cold cache and confirm the origin sees one load per key, not one per request.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Cache-aside with invalidation on Upstash Redis.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Compatibility
- Not pinned to a specific version; follows current Cache-aside behavior.
Evidence
Verified against Upstash docs: cache-aside is the documented client pattern (read-only token for client reads, writes server side); TTL via SET EX; DEL for immediate invalidation; global DB read routing for low-latency reads. Sources: https://upstash.com/docs/redis/features/restapi https://upstash.com/docs/redis/features/globaldatabase
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_aDMgLXplQXURbRxejWaaNw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Cache-aside with invalidation on Upstash Redis: the writer owns its keys <span>— Vectle</span></a>