@envelop/response-cache-cloudflare-kv 0.3.0 → 1.0.0-alpha-20240520005426-b564cd8c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -21
- package/cjs/index.js +2 -2
- package/esm/index.js +2 -2
- package/package.json +2 -2
- package/typings/index.d.cts +3 -3
- package/typings/index.d.ts +3 -3
package/README.md
CHANGED
|
@@ -33,29 +33,25 @@ import { typeDefs } from './graphql-schema/typeDefs.generated'
|
|
|
33
33
|
export type Env = {
|
|
34
34
|
GRAPHQL_RESPONSE_CACHE: KVNamespace
|
|
35
35
|
}
|
|
36
|
-
export type GraphQLContext = YogaInitialContext & Env & ExecutionContext
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ctx
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
session: () => null,
|
|
52
|
-
includeExtensionMetadata: true,
|
|
53
|
-
ttl: 1000 * 10 // 10 seconds
|
|
54
|
-
})
|
|
55
|
-
]
|
|
37
|
+
const graphqlServer = createYoga<Env & ExecutionContext>({
|
|
38
|
+
schema: createSchema({ typeDefs, resolvers }),
|
|
39
|
+
plugins: [
|
|
40
|
+
useResponseCache({
|
|
41
|
+
cache: ctx =>
|
|
42
|
+
createKvCache({
|
|
43
|
+
KV: ctx.GRAPHQL_RESPONSE_CACHE,
|
|
44
|
+
waitUntil: ctx.waitUntil,
|
|
45
|
+
keyPrefix: 'graphql' // optional
|
|
46
|
+
}),
|
|
47
|
+
session: () => null,
|
|
48
|
+
includeExtensionMetadata: true,
|
|
49
|
+
ttl: 1000 * 10 // 10 seconds
|
|
56
50
|
})
|
|
51
|
+
]
|
|
52
|
+
})
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
export default {
|
|
55
|
+
fetch: graphqlServer
|
|
60
56
|
}
|
|
61
57
|
```
|
package/cjs/index.js
CHANGED
|
@@ -40,11 +40,11 @@ function createKvCache(config) {
|
|
|
40
40
|
/** how long the operation should be cached (in milliseconds) */
|
|
41
41
|
ttl) {
|
|
42
42
|
// Do not block execution of the worker while caching the result
|
|
43
|
-
config.
|
|
43
|
+
config.waitUntil((0, set_js_1.set)(id, data, entities, ttl, config));
|
|
44
44
|
},
|
|
45
45
|
invalidate(entities) {
|
|
46
46
|
// Do not block execution of the worker while invalidating the cache
|
|
47
|
-
config.
|
|
47
|
+
config.waitUntil((0, invalidate_js_1.invalidate)(entities, config));
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
return cache;
|
package/esm/index.js
CHANGED
|
@@ -37,11 +37,11 @@ export function createKvCache(config) {
|
|
|
37
37
|
/** how long the operation should be cached (in milliseconds) */
|
|
38
38
|
ttl) {
|
|
39
39
|
// Do not block execution of the worker while caching the result
|
|
40
|
-
config.
|
|
40
|
+
config.waitUntil(set(id, data, entities, ttl, config));
|
|
41
41
|
},
|
|
42
42
|
invalidate(entities) {
|
|
43
43
|
// Do not block execution of the worker while invalidating the cache
|
|
44
|
-
config.
|
|
44
|
+
config.waitUntil(invalidate(entities, config));
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
return cache;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/response-cache-cloudflare-kv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha-20240520005426-b564cd8c",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependenciesMeta": {
|
|
6
6
|
"@cloudflare/workers-types": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@cloudflare/workers-types": "^4.20231121.0",
|
|
12
|
-
"@envelop/response-cache": "
|
|
12
|
+
"@envelop/response-cache": "6.2.0-alpha-20240520005426-b564cd8c",
|
|
13
13
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
package/typings/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
2
|
import type { Cache } from '@envelop/response-cache';
|
|
3
3
|
export type KvCacheConfig = {
|
|
4
4
|
/**
|
|
@@ -6,9 +6,9 @@ export type KvCacheConfig = {
|
|
|
6
6
|
*/
|
|
7
7
|
KV: KVNamespace;
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The function that should be used to wait for non-blocking actions to complete
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
waitUntil: (promise: Promise<unknown>) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Defines the length of time in milliseconds that a KV result is cached in the global network location it is accessed from.
|
|
14
14
|
*
|
package/typings/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
2
|
import type { Cache } from '@envelop/response-cache';
|
|
3
3
|
export type KvCacheConfig = {
|
|
4
4
|
/**
|
|
@@ -6,9 +6,9 @@ export type KvCacheConfig = {
|
|
|
6
6
|
*/
|
|
7
7
|
KV: KVNamespace;
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The function that should be used to wait for non-blocking actions to complete
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
waitUntil: (promise: Promise<unknown>) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Defines the length of time in milliseconds that a KV result is cached in the global network location it is accessed from.
|
|
14
14
|
*
|