@sdxc/cache 2026.10.13 → 2026.10.16
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/dist/adapters/worker-kv.d.ts +12 -1
- package/package.json +4 -4
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
import type { Result } from "@sdxc/result";
|
|
10
10
|
import type { JSONSerialized, JSONValue } from "@sdxc/types";
|
|
11
11
|
import type { Cache, CacheError, CacheWriteOptions } from "../index.js";
|
|
12
|
+
/**
|
|
13
|
+
* The calls this cache makes on a Workers KV binding. Declared here so a binding typed by any
|
|
14
|
+
* source fits it: a Worker's generated types, `@cloudflare/workers-types`, or a test's own.
|
|
15
|
+
*/
|
|
16
|
+
export interface WorkerKVNamespace {
|
|
17
|
+
get(key: string, type: "text"): Promise<string | null>;
|
|
18
|
+
put(key: string, value: string, options?: {
|
|
19
|
+
expirationTtl?: number;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
delete(key: string): Promise<void>;
|
|
22
|
+
}
|
|
12
23
|
/** How a Worker KV cache defers its writes. */
|
|
13
24
|
export interface WorkerKVCacheOptions {
|
|
14
25
|
/**
|
|
@@ -30,7 +41,7 @@ export declare class WorkerKVCache implements Cache {
|
|
|
30
41
|
* @param kv The namespace entries are stored in.
|
|
31
42
|
* @param options How writes are deferred.
|
|
32
43
|
*/
|
|
33
|
-
constructor(kv:
|
|
44
|
+
constructor(kv: WorkerKVNamespace, { waitUntil }?: WorkerKVCacheOptions);
|
|
34
45
|
read<T = JSONValue>(key: string): Promise<Result<JSONSerialized<T> | null, CacheError>>;
|
|
35
46
|
write<T>(key: string, value: T, options?: CacheWriteOptions): Promise<Result<void, CacheError>>;
|
|
36
47
|
fetch<T>(key: string, load: () => Promise<T>, options?: CacheWriteOptions): Promise<Result<JSONSerialized<T>, CacheError>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/cache",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.16",
|
|
4
4
|
"description": "Cache contract with adapters for memory and Cloudflare KV",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@sdxc/duration": "2026.10.13",
|
|
15
|
-
"@sdxc/logger": "2026.10.
|
|
15
|
+
"@sdxc/logger": "2026.10.16",
|
|
16
16
|
"@sdxc/result": "2026.10.13",
|
|
17
17
|
"@sdxc/types": "2026.10.13",
|
|
18
18
|
"@sdxc/uuid": "2026.10.13"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "1e547d8431568f5ed9bdb079ca3046c936240fde",
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "git+https://github.com/sergiodxa/monorepo.git",
|
|
27
27
|
"directory": "packages/cache"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://sdxc.
|
|
29
|
+
"homepage": "https://sdxc.dev/api/cache",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Sergio Xalambrí",
|
|
32
32
|
"url": "https://sergiodxa.com"
|