diigo-cache: pace diigo calls only; cache hits don't wait
page() ran the 500 ms pacing gate before the cache check, so every hit waited too: a fill rerun skipping 166 cached pages took ~80 s and looked like a start from scratch. The gate now sits after the hit check (re-checking storage once through it, in case a request ahead had just etched the page). Regression test: the fixed-clock test cache records its sleeps; a miss sleeps once, three hits add none (failed before: 4 sleeps). Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
f5d57f73d3
commit
fd16c7db53
3 files changed
+43
-8
No files matched your search
@@ -12,6 +12,7 @@ const WEBAPP_ID = "fake-webapp-id";
|
||||
type TestEnv = {
|
||||
CACHE_DO: DurableObjectNamespace<import("../src/index.js").DiigoCache>;
|
||||
PUBLIC_DO: DurableObjectNamespace<import("../src/index.js").PublicCache>;
|
||||
CLOCKED_DO: DurableObjectNamespace<import("./test-worker.js").FixedClockCache>;
|
||||
WEBAPP: { calls(): Promise<number> };
|
||||
};
|
||||
const testEnv = env as unknown as TestEnv;
|
||||
@@ -109,6 +110,18 @@ describe("page size", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("pacing", () => {
|
||||
it("paces diigo calls only: a cache hit doesn't wait", async () => {
|
||||
const stub = testEnv.CLOCKED_DO.get(testEnv.CLOCKED_DO.newUniqueId());
|
||||
await stub.setup({ webappId: WEBAPP_ID });
|
||||
await stub.page(1, PAGE_SIZE);
|
||||
const afterMiss = (await stub.sleeps()).length;
|
||||
expect(afterMiss).toBeGreaterThan(0);
|
||||
for (let i = 0; i < 3; i += 1) expect((await stub.page(1, PAGE_SIZE)).cached).toBe(true);
|
||||
expect(await stub.sleeps()).toHaveLength(afterMiss);
|
||||
});
|
||||
});
|
||||
|
||||
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