Skip to content

Commit 543da7d

Browse files
committed
fixup! share names
1 parent 797b3d4 commit 543da7d

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

packages/cloudflare/src/api/overrides/incremental-cache/kv-incremental-cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const CACHE_ASSET_DIR = "cdn-cgi/_next_cache";
77

88
export const STATUS_DELETED = 1;
99

10-
export const CACHE_NAME = "cf-kv-incremental-cache";
10+
export const NAME = "cf-kv-incremental-cache";
1111

1212
/**
1313
* Open Next cache based on cloudflare KV and Assets.
@@ -17,7 +17,7 @@ export const CACHE_NAME = "cf-kv-incremental-cache";
1717
* when the constructor is called.
1818
*/
1919
class KVIncrementalCache implements IncrementalCache {
20-
readonly name = CACHE_NAME;
20+
readonly name = NAME;
2121

2222
async get<IsFetch extends boolean = false>(
2323
key: string,

packages/cloudflare/src/api/overrides/incremental-cache/r2-incremental-cache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { IgnorableError } from "@opennextjs/aws/utils/error.js";
44

55
import { getCloudflareContext } from "../../cloudflare-context.js";
66

7+
export const NAME = "cf-r2-incremental-cache";
8+
79
/**
810
* An instance of the Incremental Cache that uses an R2 bucket (`NEXT_INC_CACHE_R2_BUCKET`) as it's
911
* underlying data store.
@@ -12,7 +14,7 @@ import { getCloudflareContext } from "../../cloudflare-context.js";
1214
* environment variable, and defaults to `incremental-cache`.
1315
*/
1416
class R2IncrementalCache implements IncrementalCache {
15-
readonly name = "cf-r2-incremental-cache";
17+
readonly name = NAME;
1618

1719
async get<IsFetch extends boolean = false>(
1820
key: string,

packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CacheValue, IncrementalCache, WithLastModified } from "@opennextjs/aws/
33

44
import { getCloudflareContext } from "../../cloudflare-context.js";
55
import { IncrementalCacheEntry } from "./internal.js";
6-
import { CACHE_NAME as KV_CACHE_NAME } from "./kv-incremental-cache.js";
6+
import { NAME as KV_CACHE_NAME } from "./kv-incremental-cache.js";
77

88
const ONE_MINUTE_IN_SECONDS = 60;
99
const THIRTY_MINUTES_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 30;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { RecoverableError } from "@opennextjs/aws/utils/error.js";
55

66
import { getCloudflareContext } from "../../cloudflare-context.js";
77

8+
export const NAME = "d1-next-mode-tag-cache";
9+
810
export class D1NextModeTagCache implements NextModeTagCache {
911
readonly mode = "nextMode" as const;
10-
readonly name = "d1-next-mode-tag-cache";
12+
readonly name = NAME;
1113

1214
async hasBeenRevalidated(tags: string[], lastModified?: number): Promise<boolean> {
1315
const { isDisabled, db } = this.getConfig();

packages/cloudflare/src/api/overrides/tag-cache/do-sharded-tag-cache.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import { IgnorableError } from "@opennextjs/aws/utils/error.js";
66

77
import { getCloudflareContext } from "../../cloudflare-context";
88

9-
const SOFT_TAG_PREFIX = "_N_T_/";
109
export const DEFAULT_WRITE_RETRIES = 3;
1110
export const DEFAULT_NUM_SHARDS = 4;
11+
export const NAME = "do-sharded-tag-cache";
12+
13+
const SOFT_TAG_PREFIX = "_N_T_/";
1214

1315
interface ShardedDOTagCacheOptions {
1416
/**
@@ -95,7 +97,7 @@ export class TagCacheDOId {
9597
}
9698
class ShardedDOTagCache implements NextModeTagCache {
9799
readonly mode = "nextMode" as const;
98-
readonly name = "do-sharded-tag-cache";
100+
readonly name = NAME;
99101
readonly numSoftReplicas: number;
100102
readonly numHardReplicas: number;
101103
readonly maxWriteRetries: number;

packages/cloudflare/src/cli/commands/populate-cache.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import type {
1212
import type { IncrementalCache, TagCache } from "@opennextjs/aws/types/overrides.js";
1313
import { globSync } from "glob";
1414

15+
import { NAME as R2_CACHE_NAME } from "../../api/overrides/incremental-cache/r2-incremental-cache.js";
16+
import { NAME as D1_TAG_NAME } from "../../api/overrides/tag-cache/d1-next-tag-cache.js";
1517
import type { WranglerTarget } from "../utils/run-wrangler.js";
1618
import { runWrangler } from "../utils/run-wrangler.js";
1719

@@ -58,7 +60,7 @@ export async function populateCache(
5860
if (!config.dangerous?.disableIncrementalCache && incrementalCache) {
5961
const name = await resolveCacheName(incrementalCache);
6062
switch (name) {
61-
case "r2-incremental-cache": {
63+
case R2_CACHE_NAME: {
6264
logger.info("\nPopulating R2 incremental cache...");
6365

6466
const assets = getCacheAssetPaths(options);
@@ -88,7 +90,7 @@ export async function populateCache(
8890
if (!config.dangerous?.disableTagCache && !config.dangerous?.disableIncrementalCache && tagCache) {
8991
const name = await resolveCacheName(tagCache);
9092
switch (name) {
91-
case "d1-next-mode-tag-cache": {
93+
case D1_TAG_NAME: {
9294
logger.info("\nCreating D1 table if necessary...");
9395

9496
runWrangler(
@@ -104,21 +106,6 @@ export async function populateCache(
104106
logger.info("\nSuccessfully created D1 table");
105107
break;
106108
}
107-
case "d1-tag-cache": {
108-
logger.info("\nPopulating D1 tag cache...");
109-
110-
runWrangler(
111-
options,
112-
[
113-
"d1 execute",
114-
"NEXT_TAG_CACHE_D1",
115-
`--file ${JSON.stringify(path.join(options.outputDir, "cloudflare/cache-assets-manifest.sql"))}`,
116-
],
117-
{ ...populateCacheOptions, logging: "error" }
118-
);
119-
logger.info("Successfully populated cache");
120-
break;
121-
}
122109
default:
123110
logger.info("Tag cache does not need populating");
124111
}

0 commit comments

Comments
 (0)