A new event is saved but visitors still see an old list. How do you reason about invalidation?
After this you can answer: A new event is saved but visitors still see an old list. How do you reason about invalidation?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”Deleting one Redis key is not sufficient when a concurrent rebuild can write the old list back afterwards. A generation number changes the namespace for all filter keys. Readers capture it before reading data; a writer advances it only after the database commit. An old rebuild cannot populate the new namespace.
Invalidation proceeds from the data outward. Dropping the Next.js data cache before Redis is advanced could make it refill from the old Redis value. The web call is deliberately not awaited by the booking or event response, and failures are logged rather than turning a committed write into an apparent failure.
Generation invalidation trades simplicity for broad churn: every booking invalidates every filtered list. At high booking volume, that can erase much of the cache benefit. Options include accepting bounded stale seat counts for browsing or separating mutable availability from event metadata. Booking correctness still comes from the locked database transaction.
Counter-questions
Section titled “Counter-questions”Can stale-while-revalidate use an old generation?
What if the web invalidation secret is wrong?
Would you invalidate on every booking forever?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Caching, then inspect the events-cache piece →.
apps/api/src/services/events.ts → invalidateEventLists
Work through the stale-cache case.
Read this book online: https://book.theversehub.in/