@mastra/valkey 0.2.1 → 0.2.2-alpha.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/dist/cache.d.ts +5 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cache.d.ts
CHANGED
|
@@ -22,5 +22,10 @@ export declare class ValkeyServerCache extends MastraServerCache {
|
|
|
22
22
|
delete(key: string): Promise<void>;
|
|
23
23
|
clear(): Promise<void>;
|
|
24
24
|
increment(key: string): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Single round-trip index allocation + list append + TTL refresh via Lua.
|
|
27
|
+
* This is the durable stream per-chunk hot path (issue #22477).
|
|
28
|
+
*/
|
|
29
|
+
listPushIndexed(listKey: string, counterKey: string, value: Record<string, unknown>): Promise<number>;
|
|
25
30
|
}
|
|
26
31
|
//# sourceMappingURL=cache.d.ts.map
|
package/dist/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,sBAAsB,C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,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAY1G;CACF"}
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1678,6 +1678,35 @@ var ValkeyStore = class extends _mastra_core_storage.MastraStorage {
|
|
|
1678
1678
|
//#endregion
|
|
1679
1679
|
//#region src/cache.ts
|
|
1680
1680
|
const stringValue = (value) => Buffer.isBuffer(value) ? value.toString() : String(value);
|
|
1681
|
+
/**
|
|
1682
|
+
* Atomic "allocate index + append + refresh TTLs" used by `listPushIndexed`.
|
|
1683
|
+
*
|
|
1684
|
+
* KEYS[1] = list key, KEYS[2] = counter key
|
|
1685
|
+
* ARGV[1] = JSON-serialized object WITHOUT an `index` property
|
|
1686
|
+
* ARGV[2] = TTL in seconds (0 = no expiry)
|
|
1687
|
+
*
|
|
1688
|
+
* The index is spliced into the JSON text as the first property rather than
|
|
1689
|
+
* decoded/re-encoded with cjson, which would silently alter large integers
|
|
1690
|
+
* and sparse arrays. `JSON.stringify` of an object always starts with `{`,
|
|
1691
|
+
* so `{...}` → `{"index":N,...}` and `{}` → `{"index":N}`.
|
|
1692
|
+
*/
|
|
1693
|
+
const LIST_PUSH_INDEXED_SCRIPT = `
|
|
1694
|
+
local i = redis.call('INCR', KEYS[2]) - 1
|
|
1695
|
+
local body = ARGV[1]
|
|
1696
|
+
local doc
|
|
1697
|
+
if #body <= 2 then
|
|
1698
|
+
doc = '{"index":' .. i .. '}'
|
|
1699
|
+
else
|
|
1700
|
+
doc = '{"index":' .. i .. ',' .. string.sub(body, 2)
|
|
1701
|
+
end
|
|
1702
|
+
redis.call('RPUSH', KEYS[1], doc)
|
|
1703
|
+
local ttl = tonumber(ARGV[2])
|
|
1704
|
+
if ttl > 0 then
|
|
1705
|
+
redis.call('EXPIRE', KEYS[1], ttl)
|
|
1706
|
+
redis.call('EXPIRE', KEYS[2], ttl)
|
|
1707
|
+
end
|
|
1708
|
+
return i
|
|
1709
|
+
`.trim();
|
|
1681
1710
|
/** GLIDE-backed Valkey cache for Mastra server state. */
|
|
1682
1711
|
var ValkeyServerCache = class extends _mastra_core_cache.MastraServerCache {
|
|
1683
1712
|
client;
|
|
@@ -1775,6 +1804,23 @@ var ValkeyServerCache = class extends _mastra_core_cache.MastraServerCache {
|
|
|
1775
1804
|
]);
|
|
1776
1805
|
return value;
|
|
1777
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Single round-trip index allocation + list append + TTL refresh via Lua.
|
|
1809
|
+
* This is the durable stream per-chunk hot path (issue #22477).
|
|
1810
|
+
*/
|
|
1811
|
+
async listPushIndexed(listKey, counterKey, value) {
|
|
1812
|
+
const { index: _ignored, ...body } = value;
|
|
1813
|
+
const result = await this.command([
|
|
1814
|
+
"EVAL",
|
|
1815
|
+
LIST_PUSH_INDEXED_SCRIPT,
|
|
1816
|
+
"2",
|
|
1817
|
+
this.getKey(listKey),
|
|
1818
|
+
this.getKey(counterKey),
|
|
1819
|
+
JSON.stringify(body),
|
|
1820
|
+
String(this.ttlSeconds)
|
|
1821
|
+
]);
|
|
1822
|
+
return Number(result);
|
|
1823
|
+
}
|
|
1778
1824
|
};
|
|
1779
1825
|
//#endregion
|
|
1780
1826
|
exports.ScoresValkey = ScoresValkey;
|