Skip to content

Commit 3519212

Browse files
committed
address review comments
1 parent 0c28284 commit 3519212

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/cloudflare/src/api/d1-tag-cache.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@ import { getCloudflareContext } from "./cloudflare-context.js";
77
// inlined during build
88
const manifest = process.env.__OPENNEXT_CACHE_TAGS_MANIFEST;
99

10+
/**
11+
* An instance of the Tag Cache that uses a D1 binding (`NEXT_CACHE_D1`) as it's underlying data store.
12+
*
13+
* The table used defaults to `tags`, but can be configured with the `NEXT_CACHE_D1_TABLE`
14+
* environment variable.
15+
*
16+
* There should be three columns created in the table; `tag`, `path`, and `revalidatedAt`.
17+
*
18+
* A combination of the D1 entries and the build-time tags manifest is used.
19+
*/
1020
class D1TagCache implements TagCache {
11-
public name = "d1-tag-cache";
21+
public readonly name = "d1-tag-cache";
1222

1323
public async getByPath(rawPath: string): Promise<string[]> {
1424
const { isDisabled, db, table } = this.getConfig();
@@ -141,10 +151,10 @@ class D1TagCache implements TagCache {
141151
const set = new Set<string>();
142152

143153
for (const arr of arrays) {
144-
arr?.forEach((v) => set.add(this.removeBuildId(v)));
154+
arr?.forEach((v) => set.add(v));
145155
}
146156

147-
return [...set.values()];
157+
return [...set.values()].map((v) => this.removeBuildId(v));
148158
}
149159
}
150160

0 commit comments

Comments
 (0)