mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #439] perf(kv): reduce KV round-trips on cache hit via local tag cache #97
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Divkix on GitHub (Mar 11, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/439
Problem
When
KVCacheHandler.get()gets a cache hit, it validates every tag by issuing onekv.get()per tag in parallel (Promise.all). For entries with 20 tags, that's 20 KV round-trips per cache hit. Same pattern inrevalidateTag()— 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 isolationImplementation
PR: #433