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
This commit is contained in:
1 parent
cffb1fa9b2
commit
904f620f06
5 files changed
+91
-1
No files matched your search
@@ -159,6 +159,30 @@ describe("page numbering (schema v2)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("invalidateRecent", () => {
|
||||
it("drops the pages holding anything updated in the last N days, and only those", async () => {
|
||||
const stub = testEnv.CACHE_DO.get(testEnv.CACHE_DO.newUniqueId());
|
||||
// deep_dee: one bookmark a day, newest first; page 1 = days 0–99,
|
||||
// page 2 = days 100–199, page 3 = days 200–299
|
||||
await stub.setup({ webappId: "fake-deep-webapp" });
|
||||
for (const n of [1, 2, 3]) await stub.page(n, PAGE_SIZE);
|
||||
expect(await stub.invalidateRecent(150)).toEqual({ pages: 2 });
|
||||
expect((await stub.page(3, PAGE_SIZE)).cached).toBe(true);
|
||||
expect((await stub.page(2, PAGE_SIZE)).cached).toBe(false);
|
||||
expect((await stub.page(1, PAGE_SIZE)).cached).toBe(false);
|
||||
});
|
||||
|
||||
it("drops nothing when nothing cached is that recent, and refuses a bad day count", async () => {
|
||||
const stub = testEnv.CACHE_DO.get(testEnv.CACHE_DO.newUniqueId());
|
||||
await stub.setup({ webappId: WEBAPP_ID }); // the plain account's dates are in 2023
|
||||
await stub.page(1, PAGE_SIZE);
|
||||
expect(await stub.invalidateRecent(7)).toEqual({ pages: 0 });
|
||||
expect((await stub.page(1, PAGE_SIZE)).cached).toBe(true);
|
||||
const refused = await stub.invalidateRecent(0).then(() => "", (e: unknown) => String(e));
|
||||
expect(refused).toMatch(/days/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("eviction", () => {
|
||||
it("a cache miss leaves no undisposed RPC stubs to block eviction", async () => {
|
||||
const stub = testEnv.CACHE_DO.get(testEnv.CACHE_DO.newUniqueId());
|
||||
|
||||
Reference in new issue
Block a user