-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Description
Problem
When KVCacheHandler.get() gets a cache hit, it validates every tag by issuing one kv.get() per tag in parallel (Promise.all). For entries with 20 tags, that's 20 KV round-trips per cache hit. Same pattern in revalidateTag() — N parallel PUTs.
Solution
Add a local in-memory Map<string, { timestamp, fetchedAt }> with a 5-second TTL that caches tag invalidation timestamps. Within the TTL window, tag checks are served from memory with zero I/O. After TTL expiry, the next request re-fetches from KV.
Key behaviors:
revalidateTag()updates the local cache immediately so invalidations are reflected without waiting for TTL expiryresetRequestCache()clears the local cache for per-request isolation- NaN tag timestamps are cached and correctly treated as invalidation
- Only uncached/expired tags trigger KV reads (partial cache hits work)
Implementation
PR: #433
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels