Skip to content

Commit 1ce819e

Browse files
committed
feat: add an experimental KV based tag cache
1 parent dcc864d commit 1ce819e

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

examples/overrides/kv-tag-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "kv-tag-next",
2+
"name": "d1-tag-next",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {

packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ export const BINDING_NAME = "NEXT_TAG_CACHE_KV";
1313
*
1414
* Warning:
1515
* This implementation is considered experimental for now.
16-
* KV is eventually consistent and can take up to 60s to reflect the last write.
16+
* KV is eventually consistency and can take up to 60s to reflect the last write.
1717
* This means that:
1818
* - revalidations can take up to 60s to apply
19-
* - when a page depends on multiple tags they can be inconsistent for up to 60s.
20-
* It also means that cached data could be outdated for one tag when other tags
21-
* are revalidated resulting in the page being generated based on outdated data.
19+
* - when a page depends on multiple tags they can be inconsistent for up to 60s
2220
*/
2321
export class KVNextModeTagCache implements NextModeTagCache {
2422
readonly mode = "nextMode" as const;
@@ -30,6 +28,7 @@ export class KVNextModeTagCache implements NextModeTagCache {
3028
return 0;
3129
}
3230

31+
console.log(`[KVNextModeTagCache] getLastRevalidated, tags=${tags}`);
3332
try {
3433
const keys = tags.map((tag) => this.getCacheKey(tag));
3534
// Use the `json` type to get back numbers/null
@@ -63,8 +62,6 @@ export class KVNextModeTagCache implements NextModeTagCache {
6362
await kv.put(this.getCacheKey(tag), timeMs);
6463
})
6564
);
66-
67-
// TODO: See https://github.com/opennextjs/opennextjs-aws/issues/986
6865
await purgeCacheByTags(tags);
6966
}
7067

0 commit comments

Comments
 (0)