Skip to content

Commit f0f3739

Browse files
export kvIncrementalCache, d1TagCache and memoryQueue from api entrypoint
1 parent 0f5e491 commit f0f3739

File tree

10 files changed

+30
-43
lines changed

10 files changed

+30
-43
lines changed

.changeset/cold-numbers-bow.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ add `defineCloudflareConfig` utility
77
this change adds a new `defineCloudflareConfig` utility that developers can use in their `open-next.config.ts`
88
file to easily generate a configuration compatible with the adapter
99

10+
as part of this change also export `kvIncrementalCache`, `d1TagCache` and `memoryQueue` from the main package entrypoint
11+
1012
Example usage:
1113

1214
```ts
1315
// open-next.config.ts
14-
import cache from "@opennextjs/cloudflare/kv-cache";
15-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
16+
import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
1617

1718
export default defineCloudflareConfig({
18-
incrementalCache: cache,
19+
incrementalCache: kvIncrementalCache,
1920
});
2021
```
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import kvCache from "@opennextjs/cloudflare/kv-cache";
2-
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
3-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache, memoryQueue } from "@opennextjs/cloudflare";
42

53
export default defineCloudflareConfig({
6-
incrementalCache: kvCache,
4+
incrementalCache: kvIncrementalCache,
75
queue: memoryQueue,
86
});
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2-
import tagCache from "@opennextjs/cloudflare/d1-tag-cache";
3-
import incrementalCache from "@opennextjs/cloudflare/kv-cache";
4-
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
1+
import { defineCloudflareConfig, kvIncrementalCache, d1TagCache, memoryQueue } from "@opennextjs/cloudflare";
52

63
export default defineCloudflareConfig({
7-
incrementalCache,
8-
tagCache,
4+
incrementalCache: kvIncrementalCache,
5+
tagCache: d1TagCache,
96
queue: memoryQueue,
107
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
2-
import cache from "@opennextjs/cloudflare/kv-cache";
3-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache, memoryQueue } from "@opennextjs/cloudflare";
42

53
export default defineCloudflareConfig({
6-
incrementalCache: cache,
4+
incrementalCache: kvIncrementalCache,
75
queue: memoryQueue,
86
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import cache from "@opennextjs/cloudflare/kv-cache";
2-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
32

43
export default defineCloudflareConfig({
5-
incrementalCache: cache,
4+
incrementalCache: kvIncrementalCache,
65
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import cache from "@opennextjs/cloudflare/kv-cache";
2-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
32

43
export default defineCloudflareConfig({
5-
incrementalCache: cache,
4+
incrementalCache: kvIncrementalCache,
65
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import cache from "@opennextjs/cloudflare/kv-cache";
2-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
32

43
export default defineCloudflareConfig({
5-
incrementalCache: cache,
4+
incrementalCache: kvIncrementalCache,
65
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import cache from "@opennextjs/cloudflare/kv-cache";
2-
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
1+
import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
32

43
export default defineCloudflareConfig({
5-
incrementalCache: cache,
4+
incrementalCache: kvIncrementalCache,
65
});

packages/cloudflare/src/api/config.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ export type CloudflareConfigOptions = {
55
/**
66
* The incremental cache implementation to use (for more details see the [Incremental Cache documentation](https://opennext.js.org/aws/config/overrides/incremental_cache))
77
*
8-
* `@opennextjs/cloudflare` offers a kv incremental cache implementation ready
9-
* to use which can be imported from `"@opennextjs/cloudflare/kv-cache"`
8+
* `@opennextjs/cloudflare` offers a kv incremental cache implementation exported as `kvIncrementalCache`
109
*
1110
* @example
12-
* import { defineCloudflareConfig } from "@opennextjs/cloudflare";
13-
* import cache from "@opennextjs/cloudflare/kv-cache";
11+
* import { defineCloudflareConfig, kvIncrementalCache } from "@opennextjs/cloudflare";
1412
*
1513
* export default defineCloudflareConfig({
1614
* incrementalCache: cache,
@@ -21,28 +19,24 @@ export type CloudflareConfigOptions = {
2119
/**
2220
* The tag cache implementation to use (for more details see the [Tag Cache documentation](https://opennext.js.org/aws/config/overrides/tag_cache))
2321
*
24-
* `@opennextjs/cloudflare` offers a d1 tag cache implementation ready
25-
* to use which can be imported from `"@opennextjs/cloudflare/d1-tag-cache"`
22+
* `@opennextjs/cloudflare` offers a d1 tag cache implementation exported as `d1TagCache`
2623
*
2724
* @example
28-
* import { defineCloudflareConfig } from "@opennextjs/cloudflare";
29-
* import cache from "@opennextjs/cloudflare/d1-tag-cache";
25+
* import { defineCloudflareConfig, d1TagCache } from "@opennextjs/cloudflare";
3026
*
3127
* export default defineCloudflareConfig({
32-
* tagCache: cache,
28+
* tagCache: d1TagCache,
3329
* });
3430
*/
3531
tagCache?: TagCache | (() => TagCache | Promise<TagCache>);
3632

3733
/**
3834
* The revalidation queue implementation to use (for more details see the [Queue documentation](https://opennext.js.org/aws/config/overrides/queue))
3935
*
40-
* `@opennextjs/cloudflare` offers an in memory queue implementation ready
41-
* to use which can be imported from `"@opennextjs/cloudflare/memory-queue"`
36+
* `@opennextjs/cloudflare` offers an in memory queue implementation exported as `memoryQueue`
4237
*
4338
* @example
44-
* import { defineCloudflareConfig } from "@opennextjs/cloudflare";
45-
* import memoryQueue from "@opennextjs/cloudflare/memory-queue";
39+
* import { defineCloudflareConfig, memoryQueue } from "@opennextjs/cloudflare";
4640
*
4741
* export default defineCloudflareConfig({
4842
* queue: memoryQueue,
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export * from "./cloudflare-context.js";
2-
export { defineCloudflareConfig } from "./config.js";
2+
export * from "./config.js";
3+
export { default as d1TagCache } from "./d1-tag-cache.js";
4+
export { default as kvIncrementalCache } from "./kv-cache";
5+
export { default as memoryQueue } from "./memory-queue.js";

0 commit comments

Comments
 (0)