@langchain/langgraph-checkpoint 0.1.0 → 1.0.0
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/CHANGELOG.md +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/base.cjs +74 -88
- package/dist/base.cjs.map +1 -0
- package/dist/base.d.cts +95 -0
- package/dist/base.d.cts.map +1 -0
- package/dist/base.d.ts +79 -73
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +69 -80
- package/dist/base.js.map +1 -1
- package/dist/cache/base.cjs +17 -21
- package/dist/cache/base.cjs.map +1 -0
- package/dist/cache/base.d.cts +43 -0
- package/dist/cache/base.d.cts.map +1 -0
- package/dist/cache/base.d.ts +41 -36
- package/dist/cache/base.d.ts.map +1 -0
- package/dist/cache/base.js +16 -16
- package/dist/cache/base.js.map +1 -1
- package/dist/cache/index.cjs +2 -19
- package/dist/cache/index.js +4 -3
- package/dist/cache/memory.cjs +53 -58
- package/dist/cache/memory.cjs.map +1 -0
- package/dist/cache/memory.d.cts +19 -0
- package/dist/cache/memory.d.cts.map +1 -0
- package/dist/cache/memory.d.ts +18 -13
- package/dist/cache/memory.d.ts.map +1 -0
- package/dist/cache/memory.js +52 -53
- package/dist/cache/memory.js.map +1 -1
- package/dist/id.cjs +12 -16
- package/dist/id.cjs.map +1 -0
- package/dist/id.d.cts +10 -0
- package/dist/id.d.cts.map +1 -0
- package/dist/id.d.ts +10 -2
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +10 -12
- package/dist/id.js.map +1 -1
- package/dist/index.cjs +36 -27
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +12 -9
- package/dist/memory.cjs +194 -268
- package/dist/memory.cjs.map +1 -0
- package/dist/memory.d.cts +22 -0
- package/dist/memory.d.cts.map +1 -0
- package/dist/memory.d.ts +19 -12
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +193 -263
- package/dist/memory.js.map +1 -1
- package/dist/serde/base.d.cts +10 -0
- package/dist/serde/base.d.cts.map +1 -0
- package/dist/serde/base.d.ts +9 -3
- package/dist/serde/base.d.ts.map +1 -0
- package/dist/serde/jsonplus.cjs +92 -141
- package/dist/serde/jsonplus.cjs.map +1 -0
- package/dist/serde/jsonplus.js +90 -136
- package/dist/serde/jsonplus.js.map +1 -1
- package/dist/serde/types.cjs +15 -9
- package/dist/serde/types.cjs.map +1 -0
- package/dist/serde/types.d.cts +55 -0
- package/dist/serde/types.d.cts.map +1 -0
- package/dist/serde/types.d.ts +53 -47
- package/dist/serde/types.d.ts.map +1 -0
- package/dist/serde/types.js +9 -5
- package/dist/serde/types.js.map +1 -1
- package/dist/serde/utils/fast-safe-stringify/index.cjs +88 -208
- package/dist/serde/utils/fast-safe-stringify/index.cjs.map +1 -0
- package/dist/serde/utils/fast-safe-stringify/index.js +87 -205
- package/dist/serde/utils/fast-safe-stringify/index.js.map +1 -1
- package/dist/store/base.cjs +200 -209
- package/dist/store/base.cjs.map +1 -0
- package/dist/store/base.d.cts +392 -0
- package/dist/store/base.d.cts.map +1 -0
- package/dist/store/base.d.ts +336 -332
- package/dist/store/base.d.ts.map +1 -0
- package/dist/store/base.js +198 -204
- package/dist/store/base.js.map +1 -1
- package/dist/store/batch.cjs +116 -147
- package/dist/store/batch.cjs.map +1 -0
- package/dist/store/batch.d.cts +49 -0
- package/dist/store/batch.d.cts.map +1 -0
- package/dist/store/batch.d.ts +48 -40
- package/dist/store/batch.d.ts.map +1 -0
- package/dist/store/batch.js +116 -143
- package/dist/store/batch.js.map +1 -1
- package/dist/store/memory.cjs +262 -363
- package/dist/store/memory.cjs.map +1 -0
- package/dist/store/memory.d.cts +64 -0
- package/dist/store/memory.d.cts.map +1 -0
- package/dist/store/memory.d.ts +30 -24
- package/dist/store/memory.d.ts.map +1 -0
- package/dist/store/memory.js +261 -358
- package/dist/store/memory.js.map +1 -1
- package/dist/store/utils.cjs +141 -249
- package/dist/store/utils.cjs.map +1 -0
- package/dist/store/utils.js +140 -245
- package/dist/store/utils.js.map +1 -1
- package/dist/types.d.cts +35 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +29 -28
- package/dist/types.d.ts.map +1 -0
- package/package.json +16 -18
- package/dist/cache/index.d.ts +0 -2
- package/dist/cache/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/serde/base.cjs +0 -3
- package/dist/serde/base.js +0 -2
- package/dist/serde/base.js.map +0 -1
- package/dist/serde/jsonplus.d.ts +0 -7
- package/dist/serde/utils/fast-safe-stringify/index.d.ts +0 -1
- package/dist/store/index.cjs +0 -20
- package/dist/store/index.d.ts +0 -3
- package/dist/store/index.js +0 -4
- package/dist/store/index.js.map +0 -1
- package/dist/store/utils.d.ts +0 -26
- package/dist/types.cjs +0 -3
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/dist/base.js
CHANGED
|
@@ -1,94 +1,83 @@
|
|
|
1
1
|
import { uuid6 } from "./id.js";
|
|
2
2
|
import { ERROR, INTERRUPT, RESUME, SCHEDULED } from "./serde/types.js";
|
|
3
3
|
import { JsonPlusSerializer } from "./serde/jsonplus.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
newObj[key] = deepCopy(obj[key]);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return newObj;
|
|
4
|
+
|
|
5
|
+
//#region src/base.ts
|
|
6
|
+
function deepCopy(obj) {
|
|
7
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
8
|
+
const newObj = Array.isArray(obj) ? [] : {};
|
|
9
|
+
for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = deepCopy(obj[key]);
|
|
10
|
+
return newObj;
|
|
15
11
|
}
|
|
16
12
|
/** @hidden */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
function emptyCheckpoint() {
|
|
14
|
+
return {
|
|
15
|
+
v: 4,
|
|
16
|
+
id: uuid6(-2),
|
|
17
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18
|
+
channel_values: {},
|
|
19
|
+
channel_versions: {},
|
|
20
|
+
versions_seen: {}
|
|
21
|
+
};
|
|
26
22
|
}
|
|
27
23
|
/** @hidden */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
function copyCheckpoint(checkpoint) {
|
|
25
|
+
return {
|
|
26
|
+
v: checkpoint.v,
|
|
27
|
+
id: checkpoint.id,
|
|
28
|
+
ts: checkpoint.ts,
|
|
29
|
+
channel_values: { ...checkpoint.channel_values },
|
|
30
|
+
channel_versions: { ...checkpoint.channel_versions },
|
|
31
|
+
versions_seen: deepCopy(checkpoint.versions_seen)
|
|
32
|
+
};
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return (current !== undefined && typeof current === "number" ? current + 1 : 1);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export function compareChannelVersions(a, b) {
|
|
66
|
-
if (typeof a === "number" && typeof b === "number") {
|
|
67
|
-
return Math.sign(a - b);
|
|
68
|
-
}
|
|
69
|
-
return String(a).localeCompare(String(b));
|
|
34
|
+
var BaseCheckpointSaver = class {
|
|
35
|
+
serde = new JsonPlusSerializer();
|
|
36
|
+
constructor(serde) {
|
|
37
|
+
this.serde = serde || this.serde;
|
|
38
|
+
}
|
|
39
|
+
async get(config) {
|
|
40
|
+
const value = await this.getTuple(config);
|
|
41
|
+
return value ? value.checkpoint : void 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generate the next version ID for a channel.
|
|
45
|
+
*
|
|
46
|
+
* Default is to use integer versions, incrementing by 1. If you override, you can use str/int/float versions,
|
|
47
|
+
* as long as they are monotonically increasing.
|
|
48
|
+
*/
|
|
49
|
+
getNextVersion(current) {
|
|
50
|
+
if (typeof current === "string") throw new Error("Please override this method to use string versions.");
|
|
51
|
+
return current !== void 0 && typeof current === "number" ? current + 1 : 1;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function compareChannelVersions(a, b) {
|
|
55
|
+
if (typeof a === "number" && typeof b === "number") return Math.sign(a - b);
|
|
56
|
+
return String(a).localeCompare(String(b));
|
|
70
57
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
58
|
+
function maxChannelVersion(...versions) {
|
|
59
|
+
return versions.reduce((max, version, idx) => {
|
|
60
|
+
if (idx === 0) return version;
|
|
61
|
+
return compareChannelVersions(max, version) >= 0 ? max : version;
|
|
62
|
+
});
|
|
77
63
|
}
|
|
78
64
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
* Mapping from error type to error index.
|
|
66
|
+
* Regular writes just map to their index in the list of writes being saved.
|
|
67
|
+
* Special writes (e.g. errors) map to negative indices, to avoid those writes from
|
|
68
|
+
* conflicting with regular writes.
|
|
69
|
+
* Each Checkpointer implementation should use this mapping in put_writes.
|
|
70
|
+
*/
|
|
71
|
+
const WRITES_IDX_MAP = {
|
|
72
|
+
[ERROR]: -1,
|
|
73
|
+
[SCHEDULED]: -2,
|
|
74
|
+
[INTERRUPT]: -3,
|
|
75
|
+
[RESUME]: -4
|
|
90
76
|
};
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
function getCheckpointId(config) {
|
|
78
|
+
return config.configurable?.checkpoint_id || config.configurable?.thread_ts || "";
|
|
93
79
|
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { BaseCheckpointSaver, WRITES_IDX_MAP, compareChannelVersions, copyCheckpoint, deepCopy, emptyCheckpoint, getCheckpointId, maxChannelVersion };
|
|
94
83
|
//# sourceMappingURL=base.js.map
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","
|
|
1
|
+
{"version":3,"file":"base.js","names":["WRITES_IDX_MAP: Record<string, number>"],"sources":["../src/base.ts"],"sourcesContent":["import type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { SerializerProtocol } from \"./serde/base.js\";\nimport { uuid6 } from \"./id.js\";\nimport type {\n PendingWrite,\n CheckpointPendingWrite,\n CheckpointMetadata,\n} from \"./types.js\";\nimport { ERROR, INTERRUPT, RESUME, SCHEDULED } from \"./serde/types.js\";\nimport { JsonPlusSerializer } from \"./serde/jsonplus.js\";\n\n/** @inline */\ntype ChannelVersion = number | string;\n\nexport type ChannelVersions = Record<string, ChannelVersion>;\n\nexport interface Checkpoint<\n N extends string = string,\n C extends string = string\n> {\n /**\n * The version of the checkpoint format. Currently 4\n */\n v: number;\n /**\n * Checkpoint ID {uuid6}\n */\n id: string;\n /**\n * Timestamp {new Date().toISOString()}\n */\n ts: string;\n /**\n * @default {}\n */\n channel_values: Record<C, unknown>;\n /**\n * @default {}\n */\n channel_versions: Record<C, ChannelVersion>;\n /**\n * @default {}\n */\n versions_seen: Record<N, Record<C, ChannelVersion>>;\n}\n\nexport interface ReadonlyCheckpoint extends Readonly<Checkpoint> {\n readonly channel_values: Readonly<Record<string, unknown>>;\n readonly channel_versions: Readonly<Record<string, ChannelVersion>>;\n readonly versions_seen: Readonly<\n Record<string, Readonly<Record<string, ChannelVersion>>>\n >;\n}\n\nexport function deepCopy<T>(obj: T): T {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n\n const newObj = Array.isArray(obj) ? [] : {};\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n (newObj as Record<PropertyKey, unknown>)[key] = deepCopy(\n (obj as Record<string, unknown>)[key]\n );\n }\n }\n\n return newObj as T;\n}\n\n/** @hidden */\nexport function emptyCheckpoint(): Checkpoint {\n return {\n v: 4,\n id: uuid6(-2),\n ts: new Date().toISOString(),\n channel_values: {},\n channel_versions: {},\n versions_seen: {},\n };\n}\n\n/** @hidden */\nexport function copyCheckpoint(checkpoint: ReadonlyCheckpoint): Checkpoint {\n return {\n v: checkpoint.v,\n id: checkpoint.id,\n ts: checkpoint.ts,\n channel_values: { ...checkpoint.channel_values },\n channel_versions: { ...checkpoint.channel_versions },\n versions_seen: deepCopy(checkpoint.versions_seen),\n };\n}\n\nexport interface CheckpointTuple {\n config: RunnableConfig;\n checkpoint: Checkpoint;\n metadata?: CheckpointMetadata;\n parentConfig?: RunnableConfig;\n pendingWrites?: CheckpointPendingWrite[];\n}\n\nexport type CheckpointListOptions = {\n limit?: number;\n before?: RunnableConfig;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n filter?: Record<string, any>;\n};\n\nexport abstract class BaseCheckpointSaver<V extends string | number = number> {\n serde: SerializerProtocol = new JsonPlusSerializer();\n\n constructor(serde?: SerializerProtocol) {\n this.serde = serde || this.serde;\n }\n\n async get(config: RunnableConfig): Promise<Checkpoint | undefined> {\n const value = await this.getTuple(config);\n return value ? value.checkpoint : undefined;\n }\n\n abstract getTuple(\n config: RunnableConfig\n ): Promise<CheckpointTuple | undefined>;\n\n abstract list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple>;\n\n abstract put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata,\n newVersions: ChannelVersions\n ): Promise<RunnableConfig>;\n\n /**\n * Store intermediate writes linked to a checkpoint.\n */\n abstract putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void>;\n\n /**\n * Delete all checkpoints and writes associated with a specific thread ID.\n * @param threadId The thread ID whose checkpoints should be deleted.\n */\n abstract deleteThread(threadId: string): Promise<void>;\n\n /**\n * Generate the next version ID for a channel.\n *\n * Default is to use integer versions, incrementing by 1. If you override, you can use str/int/float versions,\n * as long as they are monotonically increasing.\n */\n getNextVersion(current: V | undefined): V {\n if (typeof current === \"string\") {\n throw new Error(\"Please override this method to use string versions.\");\n }\n return (\n current !== undefined && typeof current === \"number\" ? current + 1 : 1\n ) as V;\n }\n}\n\nexport function compareChannelVersions(\n a: ChannelVersion,\n b: ChannelVersion\n): number {\n if (typeof a === \"number\" && typeof b === \"number\") {\n return Math.sign(a - b);\n }\n\n return String(a).localeCompare(String(b));\n}\n\nexport function maxChannelVersion(\n ...versions: ChannelVersion[]\n): ChannelVersion {\n return versions.reduce((max, version, idx) => {\n if (idx === 0) return version;\n return compareChannelVersions(max, version) >= 0 ? max : version;\n });\n}\n\n/**\n * Mapping from error type to error index.\n * Regular writes just map to their index in the list of writes being saved.\n * Special writes (e.g. errors) map to negative indices, to avoid those writes from\n * conflicting with regular writes.\n * Each Checkpointer implementation should use this mapping in put_writes.\n */\nexport const WRITES_IDX_MAP: Record<string, number> = {\n [ERROR]: -1,\n [SCHEDULED]: -2,\n [INTERRUPT]: -3,\n [RESUME]: -4,\n};\n\nexport function getCheckpointId(config: RunnableConfig): string {\n return (\n config.configurable?.checkpoint_id || config.configurable?.thread_ts || \"\"\n );\n}\n"],"mappings":";;;;;AAsDA,SAAgB,SAAY,KAAW;AACrC,KAAI,OAAO,QAAQ,YAAY,QAAQ,KACrC,QAAO;CAGT,MAAM,SAAS,MAAM,QAAQ,OAAO,KAAK;AAEzC,MAAK,MAAM,OAAO,IAChB,KAAI,OAAO,UAAU,eAAe,KAAK,KAAK,KAC5C,CAAC,OAAwC,OAAO,SAC7C,IAAgC;AAKvC,QAAO;;;AAIT,SAAgB,kBAA8B;AAC5C,QAAO;EACL,GAAG;EACH,IAAI,MAAM;EACV,qBAAI,IAAI,QAAO;EACf,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;;;;AAKnB,SAAgB,eAAe,YAA4C;AACzE,QAAO;EACL,GAAG,WAAW;EACd,IAAI,WAAW;EACf,IAAI,WAAW;EACf,gBAAgB,EAAE,GAAG,WAAW;EAChC,kBAAkB,EAAE,GAAG,WAAW;EAClC,eAAe,SAAS,WAAW;;;AAmBvC,IAAsB,sBAAtB,MAA8E;CAC5E,QAA4B,IAAI;CAEhC,YAAY,OAA4B;AACtC,OAAK,QAAQ,SAAS,KAAK;;CAG7B,MAAM,IAAI,QAAyD;EACjE,MAAM,QAAQ,MAAM,KAAK,SAAS;AAClC,SAAO,QAAQ,MAAM,aAAa;;;;;;;;CAwCpC,eAAe,SAA2B;AACxC,MAAI,OAAO,YAAY,SACrB,OAAM,IAAI,MAAM;AAElB,SACE,YAAY,UAAa,OAAO,YAAY,WAAW,UAAU,IAAI;;;AAK3E,SAAgB,uBACd,GACA,GACQ;AACR,KAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SACxC,QAAO,KAAK,KAAK,IAAI;AAGvB,QAAO,OAAO,GAAG,cAAc,OAAO;;AAGxC,SAAgB,kBACd,GAAG,UACa;AAChB,QAAO,SAAS,QAAQ,KAAK,SAAS,QAAQ;AAC5C,MAAI,QAAQ,EAAG,QAAO;AACtB,SAAO,uBAAuB,KAAK,YAAY,IAAI,MAAM;;;;;;;;;;AAW7D,MAAaA,iBAAyC;EACnD,QAAQ;EACR,YAAY;EACZ,YAAY;EACZ,SAAS;;AAGZ,SAAgB,gBAAgB,QAAgC;AAC9D,QACE,OAAO,cAAc,iBAAiB,OAAO,cAAc,aAAa"}
|
package/dist/cache/base.cjs
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
this.serde = serde || this.serde;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
const require_jsonplus = require('../serde/jsonplus.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/cache/base.ts
|
|
4
|
+
var BaseCache = class {
|
|
5
|
+
serde = new require_jsonplus.JsonPlusSerializer();
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the cache with a serializer.
|
|
8
|
+
*
|
|
9
|
+
* @param serde - The serializer to use.
|
|
10
|
+
*/
|
|
11
|
+
constructor(serde) {
|
|
12
|
+
this.serde = serde || this.serde;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
21
17
|
exports.BaseCache = BaseCache;
|
|
22
|
-
//# sourceMappingURL=base.
|
|
18
|
+
//# sourceMappingURL=base.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["JsonPlusSerializer"],"sources":["../../src/cache/base.ts"],"sourcesContent":["import { SerializerProtocol } from \"../serde/base.js\";\nimport { JsonPlusSerializer } from \"../serde/jsonplus.js\";\n\nexport type CacheNamespace = string[];\nexport type CacheFullKey = [namespace: CacheNamespace, key: string];\n\nexport abstract class BaseCache<V = unknown> {\n serde: SerializerProtocol = new JsonPlusSerializer();\n\n /**\n * Initialize the cache with a serializer.\n *\n * @param serde - The serializer to use.\n */\n constructor(serde?: SerializerProtocol) {\n this.serde = serde || this.serde;\n }\n\n /**\n * Get the cached values for the given keys.\n *\n * @param keys - The keys to get.\n */\n abstract get(\n keys: CacheFullKey[]\n ): Promise<{ key: CacheFullKey; value: V }[]>;\n\n /**\n * Set the cached values for the given keys and TTLs.\n *\n * @param pairs - The pairs to set.\n */\n abstract set(\n pairs: { key: CacheFullKey; value: V; ttl?: number }[]\n ): Promise<void>;\n\n /**\n * Delete the cached values for the given namespaces.\n * If no namespaces are provided, clear all cached values.\n *\n * @param namespaces - The namespaces to clear.\n */\n abstract clear(namespaces: CacheNamespace[]): Promise<void>;\n}\n"],"mappings":";;;AAMA,IAAsB,YAAtB,MAA6C;CAC3C,QAA4B,IAAIA;;;;;;CAOhC,YAAY,OAA4B;AACtC,OAAK,QAAQ,SAAS,KAAK"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SerializerProtocol } from "../serde/base.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cache/base.d.ts
|
|
4
|
+
type CacheNamespace = string[];
|
|
5
|
+
type CacheFullKey = [namespace: CacheNamespace, key: string];
|
|
6
|
+
declare abstract class BaseCache<V = unknown> {
|
|
7
|
+
serde: SerializerProtocol;
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the cache with a serializer.
|
|
10
|
+
*
|
|
11
|
+
* @param serde - The serializer to use.
|
|
12
|
+
*/
|
|
13
|
+
constructor(serde?: SerializerProtocol);
|
|
14
|
+
/**
|
|
15
|
+
* Get the cached values for the given keys.
|
|
16
|
+
*
|
|
17
|
+
* @param keys - The keys to get.
|
|
18
|
+
*/
|
|
19
|
+
abstract get(keys: CacheFullKey[]): Promise<{
|
|
20
|
+
key: CacheFullKey;
|
|
21
|
+
value: V;
|
|
22
|
+
}[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the cached values for the given keys and TTLs.
|
|
25
|
+
*
|
|
26
|
+
* @param pairs - The pairs to set.
|
|
27
|
+
*/
|
|
28
|
+
abstract set(pairs: {
|
|
29
|
+
key: CacheFullKey;
|
|
30
|
+
value: V;
|
|
31
|
+
ttl?: number;
|
|
32
|
+
}[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete the cached values for the given namespaces.
|
|
35
|
+
* If no namespaces are provided, clear all cached values.
|
|
36
|
+
*
|
|
37
|
+
* @param namespaces - The namespaces to clear.
|
|
38
|
+
*/
|
|
39
|
+
abstract clear(namespaces: CacheNamespace[]): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { BaseCache, CacheFullKey, CacheNamespace };
|
|
43
|
+
//# sourceMappingURL=base.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["SerializerProtocol","CacheNamespace","CacheFullKey","BaseCache","V","Promise"],"sources":["../../src/cache/base.d.ts"],"sourcesContent":["import { SerializerProtocol } from \"../serde/base.js\";\nexport type CacheNamespace = string[];\nexport type CacheFullKey = [namespace: CacheNamespace, key: string];\nexport declare abstract class BaseCache<V = unknown> {\n serde: SerializerProtocol;\n /**\n * Initialize the cache with a serializer.\n *\n * @param serde - The serializer to use.\n */\n constructor(serde?: SerializerProtocol);\n /**\n * Get the cached values for the given keys.\n *\n * @param keys - The keys to get.\n */\n abstract get(keys: CacheFullKey[]): Promise<{\n key: CacheFullKey;\n value: V;\n }[]>;\n /**\n * Set the cached values for the given keys and TTLs.\n *\n * @param pairs - The pairs to set.\n */\n abstract set(pairs: {\n key: CacheFullKey;\n value: V;\n ttl?: number;\n }[]): Promise<void>;\n /**\n * Delete the cached values for the given namespaces.\n * If no namespaces are provided, clear all cached values.\n *\n * @param namespaces - The namespaces to clear.\n */\n abstract clear(namespaces: CacheNamespace[]): Promise<void>;\n}\n"],"mappings":";;;KACYC,cAAAA;KACAC,YAAAA,eAA2BD;AAD3BA,uBAEkBE,SAFJ,CAAA,IAAA,OAAA,CAAA,CAAA;EACdD,KAAAA,EAEDF,kBAFa;EACMG;;;;;aAcjBD,CAAAA,KAAAA,CAAAA,EAPWF,kBAOXE;;;;;;WAmBkBD,GAAAA,CAAAA,IAAAA,EApBRC,YAoBQD,EAAAA,CAAAA,EApBSI,OAoBTJ,CAAAA;IAAmBI,GAAAA,EAnBrCH,YAmBqCG;WAlBnCD;;;;;;;;SAQFF;WACEE;;QAELC;;;;;;;6BAOqBJ,mBAAmBI"}
|
package/dist/cache/base.d.ts
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
import { SerializerProtocol } from "../serde/base.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/cache/base.d.ts
|
|
4
|
+
type CacheNamespace = string[];
|
|
5
|
+
type CacheFullKey = [namespace: CacheNamespace, key: string];
|
|
6
|
+
declare abstract class BaseCache<V = unknown> {
|
|
7
|
+
serde: SerializerProtocol;
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the cache with a serializer.
|
|
10
|
+
*
|
|
11
|
+
* @param serde - The serializer to use.
|
|
12
|
+
*/
|
|
13
|
+
constructor(serde?: SerializerProtocol);
|
|
14
|
+
/**
|
|
15
|
+
* Get the cached values for the given keys.
|
|
16
|
+
*
|
|
17
|
+
* @param keys - The keys to get.
|
|
18
|
+
*/
|
|
19
|
+
abstract get(keys: CacheFullKey[]): Promise<{
|
|
20
|
+
key: CacheFullKey;
|
|
21
|
+
value: V;
|
|
22
|
+
}[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the cached values for the given keys and TTLs.
|
|
25
|
+
*
|
|
26
|
+
* @param pairs - The pairs to set.
|
|
27
|
+
*/
|
|
28
|
+
abstract set(pairs: {
|
|
29
|
+
key: CacheFullKey;
|
|
30
|
+
value: V;
|
|
31
|
+
ttl?: number;
|
|
32
|
+
}[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete the cached values for the given namespaces.
|
|
35
|
+
* If no namespaces are provided, clear all cached values.
|
|
36
|
+
*
|
|
37
|
+
* @param namespaces - The namespaces to clear.
|
|
38
|
+
*/
|
|
39
|
+
abstract clear(namespaces: CacheNamespace[]): Promise<void>;
|
|
38
40
|
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { BaseCache, CacheFullKey, CacheNamespace };
|
|
43
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":["SerializerProtocol","CacheNamespace","CacheFullKey","BaseCache","V","Promise"],"sources":["../../src/cache/base.d.ts"],"sourcesContent":["import { SerializerProtocol } from \"../serde/base.js\";\nexport type CacheNamespace = string[];\nexport type CacheFullKey = [namespace: CacheNamespace, key: string];\nexport declare abstract class BaseCache<V = unknown> {\n serde: SerializerProtocol;\n /**\n * Initialize the cache with a serializer.\n *\n * @param serde - The serializer to use.\n */\n constructor(serde?: SerializerProtocol);\n /**\n * Get the cached values for the given keys.\n *\n * @param keys - The keys to get.\n */\n abstract get(keys: CacheFullKey[]): Promise<{\n key: CacheFullKey;\n value: V;\n }[]>;\n /**\n * Set the cached values for the given keys and TTLs.\n *\n * @param pairs - The pairs to set.\n */\n abstract set(pairs: {\n key: CacheFullKey;\n value: V;\n ttl?: number;\n }[]): Promise<void>;\n /**\n * Delete the cached values for the given namespaces.\n * If no namespaces are provided, clear all cached values.\n *\n * @param namespaces - The namespaces to clear.\n */\n abstract clear(namespaces: CacheNamespace[]): Promise<void>;\n}\n"],"mappings":";;;KACYC,cAAAA;KACAC,YAAAA,eAA2BD;AAD3BA,uBAEkBE,SAFJ,CAAA,IAAA,OAAA,CAAA,CAAA;EACdD,KAAAA,EAEDF,kBAFa;EACMG;;;;;aAcjBD,CAAAA,KAAAA,CAAAA,EAPWF,kBAOXE;;;;;;WAmBkBD,GAAAA,CAAAA,IAAAA,EApBRC,YAoBQD,EAAAA,CAAAA,EApBSI,OAoBTJ,CAAAA;IAAmBI,GAAAA,EAnBrCH,YAmBqCG;WAlBnCD;;;;;;;;SAQFF;WACEE;;QAELC;;;;;;;6BAOqBJ,mBAAmBI"}
|
package/dist/cache/base.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { JsonPlusSerializer } from "../serde/jsonplus.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
2
|
+
|
|
3
|
+
//#region src/cache/base.ts
|
|
4
|
+
var BaseCache = class {
|
|
5
|
+
serde = new JsonPlusSerializer();
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the cache with a serializer.
|
|
8
|
+
*
|
|
9
|
+
* @param serde - The serializer to use.
|
|
10
|
+
*/
|
|
11
|
+
constructor(serde) {
|
|
12
|
+
this.serde = serde || this.serde;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { BaseCache };
|
|
18
18
|
//# sourceMappingURL=base.js.map
|
package/dist/cache/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/cache/base.ts"],"sourcesContent":["import { SerializerProtocol } from \"../serde/base.js\";\nimport { JsonPlusSerializer } from \"../serde/jsonplus.js\";\n\nexport type CacheNamespace = string[];\nexport type CacheFullKey = [namespace: CacheNamespace, key: string];\n\nexport abstract class BaseCache<V = unknown> {\n serde: SerializerProtocol = new JsonPlusSerializer();\n\n /**\n * Initialize the cache with a serializer.\n *\n * @param serde - The serializer to use.\n */\n constructor(serde?: SerializerProtocol) {\n this.serde = serde || this.serde;\n }\n\n /**\n * Get the cached values for the given keys.\n *\n * @param keys - The keys to get.\n */\n abstract get(\n keys: CacheFullKey[]\n ): Promise<{ key: CacheFullKey; value: V }[]>;\n\n /**\n * Set the cached values for the given keys and TTLs.\n *\n * @param pairs - The pairs to set.\n */\n abstract set(\n pairs: { key: CacheFullKey; value: V; ttl?: number }[]\n ): Promise<void>;\n\n /**\n * Delete the cached values for the given namespaces.\n * If no namespaces are provided, clear all cached values.\n *\n * @param namespaces - The namespaces to clear.\n */\n abstract clear(namespaces: CacheNamespace[]): Promise<void>;\n}\n"],"mappings":";;;AAMA,IAAsB,YAAtB,MAA6C;CAC3C,QAA4B,IAAI;;;;;;CAOhC,YAAY,OAA4B;AACtC,OAAK,QAAQ,SAAS,KAAK"}
|
package/dist/cache/index.cjs
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base.cjs"), exports);
|
|
18
|
-
__exportStar(require("./memory.cjs"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
const require_base = require('./base.cjs');
|
|
2
|
+
const require_memory = require('./memory.cjs');
|
package/dist/cache/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BaseCache } from "./base.js";
|
|
2
|
+
import { InMemoryCache } from "./memory.js";
|
|
3
|
+
|
|
4
|
+
export { };
|
package/dist/cache/memory.cjs
CHANGED
|
@@ -1,59 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (strNamespace in this.cache)
|
|
54
|
-
delete this.cache[strNamespace];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
const require_base = require('./base.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/cache/memory.ts
|
|
4
|
+
var InMemoryCache = class extends require_base.BaseCache {
|
|
5
|
+
cache = {};
|
|
6
|
+
async get(keys) {
|
|
7
|
+
if (!keys.length) return [];
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
return (await Promise.all(keys.map(async (fullKey) => {
|
|
10
|
+
const [namespace, key] = fullKey;
|
|
11
|
+
const strNamespace = namespace.join(",");
|
|
12
|
+
if (strNamespace in this.cache && key in this.cache[strNamespace]) {
|
|
13
|
+
const cached = this.cache[strNamespace][key];
|
|
14
|
+
if (cached.exp == null || now < cached.exp) {
|
|
15
|
+
const value = await this.serde.loadsTyped(cached.enc, cached.val);
|
|
16
|
+
return [{
|
|
17
|
+
key: fullKey,
|
|
18
|
+
value
|
|
19
|
+
}];
|
|
20
|
+
} else delete this.cache[strNamespace][key];
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
}))).flat();
|
|
24
|
+
}
|
|
25
|
+
async set(pairs) {
|
|
26
|
+
const now = Date.now();
|
|
27
|
+
for (const { key: fullKey, value, ttl } of pairs) {
|
|
28
|
+
const [namespace, key] = fullKey;
|
|
29
|
+
const strNamespace = namespace.join(",");
|
|
30
|
+
const [enc, val] = await this.serde.dumpsTyped(value);
|
|
31
|
+
const exp = ttl != null ? ttl * 1e3 + now : null;
|
|
32
|
+
this.cache[strNamespace] ??= {};
|
|
33
|
+
this.cache[strNamespace][key] = {
|
|
34
|
+
enc,
|
|
35
|
+
val,
|
|
36
|
+
exp
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async clear(namespaces) {
|
|
41
|
+
if (!namespaces.length) {
|
|
42
|
+
this.cache = {};
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const namespace of namespaces) {
|
|
46
|
+
const strNamespace = namespace.join(",");
|
|
47
|
+
if (strNamespace in this.cache) delete this.cache[strNamespace];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
58
53
|
exports.InMemoryCache = InMemoryCache;
|
|
59
|
-
//# sourceMappingURL=memory.
|
|
54
|
+
//# sourceMappingURL=memory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.cjs","names":["BaseCache"],"sources":["../../src/cache/memory.ts"],"sourcesContent":["import { BaseCache, type CacheFullKey, type CacheNamespace } from \"./base.js\";\n\nexport class InMemoryCache<V = unknown> extends BaseCache<V> {\n private cache: {\n [namespace: string]: {\n [key: string]: {\n enc: string;\n val: Uint8Array | string;\n exp: number | null;\n };\n };\n } = {};\n\n async get(keys: CacheFullKey[]): Promise<{ key: CacheFullKey; value: V }[]> {\n if (!keys.length) return [];\n const now = Date.now();\n return (\n await Promise.all(\n keys.map(\n async (fullKey): Promise<{ key: CacheFullKey; value: V }[]> => {\n const [namespace, key] = fullKey;\n const strNamespace = namespace.join(\",\");\n\n if (strNamespace in this.cache && key in this.cache[strNamespace]) {\n const cached = this.cache[strNamespace][key];\n if (cached.exp == null || now < cached.exp) {\n const value = await this.serde.loadsTyped(\n cached.enc,\n cached.val\n );\n return [{ key: fullKey, value }];\n } else {\n delete this.cache[strNamespace][key];\n }\n }\n\n return [];\n }\n )\n )\n ).flat();\n }\n\n async set(\n pairs: { key: CacheFullKey; value: V; ttl?: number }[]\n ): Promise<void> {\n const now = Date.now();\n for (const { key: fullKey, value, ttl } of pairs) {\n const [namespace, key] = fullKey;\n const strNamespace = namespace.join(\",\");\n const [enc, val] = await this.serde.dumpsTyped(value);\n const exp = ttl != null ? ttl * 1000 + now : null;\n\n this.cache[strNamespace] ??= {};\n this.cache[strNamespace][key] = { enc, val, exp };\n }\n }\n\n async clear(namespaces: CacheNamespace[]): Promise<void> {\n if (!namespaces.length) {\n this.cache = {};\n return;\n }\n\n for (const namespace of namespaces) {\n const strNamespace = namespace.join(\",\");\n if (strNamespace in this.cache) delete this.cache[strNamespace];\n }\n }\n}\n"],"mappings":";;;AAEA,IAAa,gBAAb,cAAgDA,uBAAa;CAC3D,AAAQ,QAQJ;CAEJ,MAAM,IAAI,MAAkE;AAC1E,MAAI,CAAC,KAAK,OAAQ,QAAO;EACzB,MAAM,MAAM,KAAK;AACjB,UACE,MAAM,QAAQ,IACZ,KAAK,IACH,OAAO,YAAwD;GAC7D,MAAM,CAAC,WAAW,OAAO;GACzB,MAAM,eAAe,UAAU,KAAK;AAEpC,OAAI,gBAAgB,KAAK,SAAS,OAAO,KAAK,MAAM,eAAe;IACjE,MAAM,SAAS,KAAK,MAAM,cAAc;AACxC,QAAI,OAAO,OAAO,QAAQ,MAAM,OAAO,KAAK;KAC1C,MAAM,QAAQ,MAAM,KAAK,MAAM,WAC7B,OAAO,KACP,OAAO;AAET,YAAO,CAAC;MAAE,KAAK;MAAS;;UAExB,QAAO,KAAK,MAAM,cAAc;;AAIpC,UAAO;OAIb;;CAGJ,MAAM,IACJ,OACe;EACf,MAAM,MAAM,KAAK;AACjB,OAAK,MAAM,EAAE,KAAK,SAAS,OAAO,SAAS,OAAO;GAChD,MAAM,CAAC,WAAW,OAAO;GACzB,MAAM,eAAe,UAAU,KAAK;GACpC,MAAM,CAAC,KAAK,OAAO,MAAM,KAAK,MAAM,WAAW;GAC/C,MAAM,MAAM,OAAO,OAAO,MAAM,MAAO,MAAM;AAE7C,QAAK,MAAM,kBAAkB;AAC7B,QAAK,MAAM,cAAc,OAAO;IAAE;IAAK;IAAK;;;;CAIhD,MAAM,MAAM,YAA6C;AACvD,MAAI,CAAC,WAAW,QAAQ;AACtB,QAAK,QAAQ;AACb;;AAGF,OAAK,MAAM,aAAa,YAAY;GAClC,MAAM,eAAe,UAAU,KAAK;AACpC,OAAI,gBAAgB,KAAK,MAAO,QAAO,KAAK,MAAM"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCache, CacheFullKey, CacheNamespace } from "./base.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cache/memory.d.ts
|
|
4
|
+
declare class InMemoryCache<V = unknown> extends BaseCache<V> {
|
|
5
|
+
private cache;
|
|
6
|
+
get(keys: CacheFullKey[]): Promise<{
|
|
7
|
+
key: CacheFullKey;
|
|
8
|
+
value: V;
|
|
9
|
+
}[]>;
|
|
10
|
+
set(pairs: {
|
|
11
|
+
key: CacheFullKey;
|
|
12
|
+
value: V;
|
|
13
|
+
ttl?: number;
|
|
14
|
+
}[]): Promise<void>;
|
|
15
|
+
clear(namespaces: CacheNamespace[]): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { InMemoryCache };
|
|
19
|
+
//# sourceMappingURL=memory.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.cts","names":["BaseCache","CacheFullKey","CacheNamespace","InMemoryCache","V","Promise"],"sources":["../../src/cache/memory.d.ts"],"sourcesContent":["import { BaseCache, type CacheFullKey, type CacheNamespace } from \"./base.js\";\nexport declare class InMemoryCache<V = unknown> extends BaseCache<V> {\n private cache;\n get(keys: CacheFullKey[]): Promise<{\n key: CacheFullKey;\n value: V;\n }[]>;\n set(pairs: {\n key: CacheFullKey;\n value: V;\n ttl?: number;\n }[]): Promise<void>;\n clear(namespaces: CacheNamespace[]): Promise<void>;\n}\n"],"mappings":";;;cACqBG,mCAAmCH,UAAUI;;EAA7CD,GAAAA,CAAAA,IAAAA,EAEPF,YAFoB,EAAA,CAAA,EAEHI,OAFG,CAAA;IAAA,GAAA,EAGrBJ,YAHqB;IAAgCG,KAAAA,EAInDA,CAJmDA;KAEpDH,CAAAA;KACDA,CAAAA,KAAAA,EAAAA;IACEG,GAAAA,EAGFH,YAHEG;IAFgBC,KAAAA,EAMhBD,CANgBC;IAKlBJ,GAAAA,CAAAA,EAAAA,MAAAA;KACEG,CAAAA,EAELC,OAFKD,CAAAA,IAAAA,CAAAA;OAELC,CAAAA,UAAAA,EACYH,cADZG,EAAAA,CAAAA,EAC+BA,OAD/BA,CAAAA,IAAAA,CAAAA"}
|