From 904f620f06f973715272868f8d2f5f891f3ce196 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 7 Oct 2026 08:27:13 -0500 Subject: [PATCH] diigo-cache: invalidate the last N days of cached pages invalidateRecent(days) drops the cached pages holding anything diigo updated within the last N days (on the cache's injected clock), and every page before them, so the next read or fill refetches them; item rows stay. Exposed on the fill capability (private and public) and on the webkey page as "invalidate the last N days" per cache. A user-requested refetch, not a change in what stored state means. Generated-by: Claude Opus 5.5 --- diigo-cache/src/api.ts | 10 +++++++++- diigo-cache/src/cache-page.ts | 13 +++++++++++++ diigo-cache/src/cache.ts | 31 +++++++++++++++++++++++++++++++ diigo-cache/tests/caches.test.ts | 24 ++++++++++++++++++++++++ diigo-cache/tests/fill.test.ts | 14 ++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) diff --git a/diigo-cache/src/api.ts b/diigo-cache/src/api.ts index 745cd9b..f200ec3 100644 --- a/diigo-cache/src/api.ts +++ b/diigo-cache/src/api.ts @@ -28,9 +28,10 @@ type Fillable = { startFill(opts?: { pagesPerStep?: number }): Promise; fillStatus(): Promise; stopFill(): Promise; + invalidateRecent(days: number): Promise<{ pages: number }>; }; -/** a cache's fill job, and nothing else */ +/** a cache's fill job and page invalidation, and nothing else */ export class FillCap extends RpcTarget { #cache: Fillable; @@ -55,6 +56,13 @@ export class FillCap extends RpcTarget { async stopFill(): Promise { return this.#cache.stopFill(); } + + /** drop the cached pages holding anything updated in the last `days` + * days (1–3650), so they refetch */ + async invalidateRecent(days: unknown): Promise<{ pages: number }> { + if (typeof days !== "number") throw new Error("days: expected a number"); + return this.#cache.invalidateRecent(days); + } } /** what the holder of a private cache's key may do */ diff --git a/diigo-cache/src/cache-page.ts b/diigo-cache/src/cache-page.ts index c019f62..b34d1ae 100644 --- a/diigo-cache/src/cache-page.ts +++ b/diigo-cache/src/cache-page.ts @@ -28,12 +28,18 @@ export const CACHE_PAGE_HTML = `

no fill job yet

+

+ +

← home