Cache keys carry the model version
Origin: baselineStatus: confirmedRepo: tidewatch-apiWritten: 19 Sept 2026
What
A station and day never changes, so predictions are cached for 30 days. The key includes MODEL_VERSION, so a model change needs no cache flush: bump the number and old entries are never read again.
Cites
Believed before
You have to flush Redis after changing the model.
True now
You bump MODEL_VERSION. Nothing is flushed.
Cites
- [1]src/cache.ts:1-8matchEntire fileSupports: what[THIS IS THE ENTIRE FILE, 8 lines]
// Predictions for a station and day never change, so they are cached for a long time.// The key carries the MODEL VERSION: bump it and every old entry is simply never read again.export const MODEL_VERSION = 3;export const TTL_SECONDS = 60 * 60 * 24 * 30;export function cacheKey(stationId: string, isoDay: string): string {return `tide:v${MODEL_VERSION}:${stationId}:${isoDay}`;}
Card
How do you invalidate every cached Tidewatch prediction?
midShow the answerHide the answer
Bump MODEL_VERSION in src/cache.ts. The key is tide:v<version>:<station>:<day>, so old entries are never read and expire after 30 days.
Cites[1]