encore.dev 1.54.2 → 1.56.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.
Files changed (41) hide show
  1. package/config/secrets.ts +7 -1
  2. package/dist/config/secrets.js +4 -0
  3. package/dist/config/secrets.js.map +1 -1
  4. package/dist/internal/runtime/napi/napi.cjs +3 -1
  5. package/dist/internal/runtime/napi/napi.d.cts +114 -1
  6. package/dist/storage/cache/basic.d.ts +268 -0
  7. package/dist/storage/cache/basic.js +383 -0
  8. package/dist/storage/cache/basic.js.map +1 -0
  9. package/dist/storage/cache/cluster.d.ts +48 -0
  10. package/dist/storage/cache/cluster.js +40 -0
  11. package/dist/storage/cache/cluster.js.map +1 -0
  12. package/dist/storage/cache/errors.d.ts +19 -0
  13. package/dist/storage/cache/errors.js +59 -0
  14. package/dist/storage/cache/errors.js.map +1 -0
  15. package/dist/storage/cache/expiry.d.ts +55 -0
  16. package/dist/storage/cache/expiry.js +74 -0
  17. package/dist/storage/cache/expiry.js.map +1 -0
  18. package/dist/storage/cache/keyspace.d.ts +77 -0
  19. package/dist/storage/cache/keyspace.js +100 -0
  20. package/dist/storage/cache/keyspace.js.map +1 -0
  21. package/dist/storage/cache/list.d.ts +249 -0
  22. package/dist/storage/cache/list.js +376 -0
  23. package/dist/storage/cache/list.js.map +1 -0
  24. package/dist/storage/cache/mod.d.ts +10 -0
  25. package/dist/storage/cache/mod.js +13 -0
  26. package/dist/storage/cache/mod.js.map +1 -0
  27. package/dist/storage/cache/set.d.ts +258 -0
  28. package/dist/storage/cache/set.js +411 -0
  29. package/dist/storage/cache/set.js.map +1 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/internal/runtime/napi/napi.cjs +3 -1
  32. package/internal/runtime/napi/napi.d.cts +114 -1
  33. package/package.json +6 -1
  34. package/storage/cache/basic.ts +511 -0
  35. package/storage/cache/cluster.ts +67 -0
  36. package/storage/cache/errors.ts +66 -0
  37. package/storage/cache/expiry.ts +98 -0
  38. package/storage/cache/keyspace.ts +142 -0
  39. package/storage/cache/list.ts +496 -0
  40. package/storage/cache/mod.ts +36 -0
  41. package/storage/cache/set.ts +491 -0
@@ -0,0 +1,376 @@
1
+ import { getCurrentRequest } from "../../internal/reqtrack/mod.js";
2
+ import { Keyspace } from "./keyspace.js";
3
+ /**
4
+ * Base class for list keyspaces with all list operations.
5
+ * Subclasses provide typed serialization/deserialization.
6
+ * @internal
7
+ */
8
+ class ListKeyspace extends Keyspace {
9
+ constructor(cluster, config) {
10
+ super(cluster, config);
11
+ }
12
+ /**
13
+ * Pushes one or more values at the head of the list stored at key.
14
+ * If the key does not already exist, it is first created as an empty list.
15
+ *
16
+ * If multiple values are given, they are inserted one after another,
17
+ * starting with the leftmost value. For instance,
18
+ * `pushLeft(key, "a", "b", "c")` will result in a list containing
19
+ * "c" as its first element, "b" as its second, and "a" as its third.
20
+ *
21
+ * @returns The length of the list after the operation.
22
+ * @see https://redis.io/commands/lpush/
23
+ */
24
+ async pushLeft(key, ...values) {
25
+ const source = getCurrentRequest();
26
+ const mappedKey = this.mapKey(key);
27
+ const serialized = values.map((v) => this.serializeItem(v));
28
+ const ttlMs = this.resolveTtl();
29
+ const result = await this.cluster.impl.lpush(mappedKey, serialized, ttlMs, source);
30
+ return Number(result);
31
+ }
32
+ /**
33
+ * Pushes one or more values at the tail of the list stored at key.
34
+ * If the key does not already exist, it is first created as an empty list.
35
+ *
36
+ * If multiple values are given, they are inserted one after another,
37
+ * starting with the leftmost value. For instance,
38
+ * `pushRight(key, "a", "b", "c")` will result in a list containing
39
+ * "a" as its first element, "b" as its second, and "c" as its third.
40
+ *
41
+ * @returns The length of the list after the operation.
42
+ * @see https://redis.io/commands/rpush/
43
+ */
44
+ async pushRight(key, ...values) {
45
+ const source = getCurrentRequest();
46
+ const mappedKey = this.mapKey(key);
47
+ const serialized = values.map((v) => this.serializeItem(v));
48
+ const ttlMs = this.resolveTtl();
49
+ const result = await this.cluster.impl.rpush(mappedKey, serialized, ttlMs, source);
50
+ return Number(result);
51
+ }
52
+ /**
53
+ * Pops a single element off the head of the list stored at key.
54
+ *
55
+ * @returns The popped value, or `undefined` if the key does not exist.
56
+ * @see https://redis.io/commands/lpop/
57
+ */
58
+ async popLeft(key, options) {
59
+ const source = getCurrentRequest();
60
+ const mappedKey = this.mapKey(key);
61
+ const ttlMs = this.resolveTtl(options);
62
+ const result = await this.cluster.impl.lpop(mappedKey, ttlMs, source);
63
+ if (result === null) {
64
+ return undefined;
65
+ }
66
+ return this.deserializeItem(result);
67
+ }
68
+ /**
69
+ * Pops a single element off the tail of the list stored at key.
70
+ *
71
+ * @returns The popped value, or `undefined` if the key does not exist.
72
+ * @see https://redis.io/commands/rpop/
73
+ */
74
+ async popRight(key, options) {
75
+ const source = getCurrentRequest();
76
+ const mappedKey = this.mapKey(key);
77
+ const ttlMs = this.resolveTtl(options);
78
+ const result = await this.cluster.impl.rpop(mappedKey, ttlMs, source);
79
+ if (result === null) {
80
+ return undefined;
81
+ }
82
+ return this.deserializeItem(result);
83
+ }
84
+ /**
85
+ * Returns the length of the list stored at key.
86
+ *
87
+ * Non-existing keys are considered as empty lists.
88
+ *
89
+ * @returns The list length.
90
+ * @see https://redis.io/commands/llen/
91
+ */
92
+ async len(key) {
93
+ const source = getCurrentRequest();
94
+ const mappedKey = this.mapKey(key);
95
+ const result = await this.cluster.impl.llen(mappedKey, source);
96
+ return Number(result);
97
+ }
98
+ /**
99
+ * Trims the list stored at key to only contain the elements between the indices
100
+ * `start` and `stop` (inclusive). Both are zero-based indices.
101
+ *
102
+ * Negative indices can be used to indicate offsets from the end of the list,
103
+ * where -1 is the last element of the list, -2 the penultimate element, and so on.
104
+ *
105
+ * Out of range indices are valid and are treated as if they specify the start or end of the list,
106
+ * respectively. If `start` > `stop` the end result is an empty list.
107
+ *
108
+ * @param key - The cache key.
109
+ * @param start - Start index (inclusive).
110
+ * @param stop - Stop index (inclusive).
111
+ * @see https://redis.io/commands/ltrim/
112
+ */
113
+ async trim(key, start, stop, options) {
114
+ const source = getCurrentRequest();
115
+ const mappedKey = this.mapKey(key);
116
+ const ttlMs = this.resolveTtl(options);
117
+ await this.cluster.impl.ltrim(mappedKey, start, stop, ttlMs, source);
118
+ }
119
+ /**
120
+ * Updates the list element at the given index.
121
+ *
122
+ * Negative indices can be used to indicate offsets from the end of the list,
123
+ * where -1 is the last element of the list, -2 the penultimate element, and so on.
124
+ *
125
+ * @param key - The cache key.
126
+ * @param index - Zero-based index of the element to update.
127
+ * @param value - The new value.
128
+ * @throws {Error} If the index is out of range.
129
+ * @see https://redis.io/commands/lset/
130
+ */
131
+ async set(key, index, value, options) {
132
+ const source = getCurrentRequest();
133
+ const mappedKey = this.mapKey(key);
134
+ const serialized = this.serializeItem(value);
135
+ const ttlMs = this.resolveTtl(options);
136
+ await this.cluster.impl.lset(mappedKey, index, serialized, ttlMs, source);
137
+ }
138
+ /**
139
+ * Returns the value of the list element at the given index.
140
+ *
141
+ * Negative indices can be used to indicate offsets from the end of the list,
142
+ * where -1 is the last element of the list, -2 the penultimate element, and so on.
143
+ *
144
+ * @param key - The cache key.
145
+ * @param index - Zero-based index of the element to retrieve.
146
+ * @returns The value at the index, or `undefined` if out of range or the key does not exist.
147
+ * @see https://redis.io/commands/lindex/
148
+ */
149
+ async get(key, index) {
150
+ const source = getCurrentRequest();
151
+ const mappedKey = this.mapKey(key);
152
+ const result = await this.cluster.impl.lindex(mappedKey, index, source);
153
+ if (result === null) {
154
+ return undefined;
155
+ }
156
+ return this.deserializeItem(result);
157
+ }
158
+ /**
159
+ * Returns all the elements in the list stored at key.
160
+ *
161
+ * If the key does not exist it returns an empty array.
162
+ *
163
+ * @returns All elements in the list.
164
+ * @see https://redis.io/commands/lrange/
165
+ */
166
+ async items(key) {
167
+ const source = getCurrentRequest();
168
+ const mappedKey = this.mapKey(key);
169
+ const results = await this.cluster.impl.lrangeAll(mappedKey, source);
170
+ return results.map((r) => this.deserializeItem(r));
171
+ }
172
+ /**
173
+ * Returns the elements in the list stored at key between `start` and `stop` (inclusive).
174
+ * Both are zero-based indices.
175
+ *
176
+ * Negative indices can be used to indicate offsets from the end of the list,
177
+ * where -1 is the last element of the list, -2 the penultimate element, and so on.
178
+ *
179
+ * If the key does not exist it returns an empty array.
180
+ *
181
+ * @param key - The cache key.
182
+ * @param start - Start index (inclusive).
183
+ * @param stop - Stop index (inclusive).
184
+ * @returns The elements in the specified range.
185
+ * @see https://redis.io/commands/lrange/
186
+ */
187
+ async getRange(key, start, stop) {
188
+ const source = getCurrentRequest();
189
+ const mappedKey = this.mapKey(key);
190
+ const results = await this.cluster.impl.lrange(mappedKey, start, stop, source);
191
+ return results.map((r) => this.deserializeItem(r));
192
+ }
193
+ /**
194
+ * Inserts `value` into the list stored at key, at the position just before `pivot`.
195
+ *
196
+ * If the list does not contain `pivot`, the value is not inserted and -1 is returned.
197
+ *
198
+ * @param key - The cache key.
199
+ * @param pivot - The existing element to insert before.
200
+ * @param value - The value to insert.
201
+ * @returns The new list length, or -1 if `pivot` was not found.
202
+ * @see https://redis.io/commands/linsert/
203
+ */
204
+ async insertBefore(key, pivot, value, options) {
205
+ const source = getCurrentRequest();
206
+ const mappedKey = this.mapKey(key);
207
+ const pivotSerialized = this.serializeItem(pivot);
208
+ const valueSerialized = this.serializeItem(value);
209
+ const ttlMs = this.resolveTtl(options);
210
+ const result = await this.cluster.impl.linsertBefore(mappedKey, pivotSerialized, valueSerialized, ttlMs, source);
211
+ return Number(result);
212
+ }
213
+ /**
214
+ * Inserts `value` into the list stored at key, at the position just after `pivot`.
215
+ *
216
+ * If the list does not contain `pivot`, the value is not inserted and -1 is returned.
217
+ *
218
+ * @param key - The cache key.
219
+ * @param pivot - The existing element to insert after.
220
+ * @param value - The value to insert.
221
+ * @returns The new list length, or -1 if `pivot` was not found.
222
+ * @see https://redis.io/commands/linsert/
223
+ */
224
+ async insertAfter(key, pivot, value, options) {
225
+ const source = getCurrentRequest();
226
+ const mappedKey = this.mapKey(key);
227
+ const pivotSerialized = this.serializeItem(pivot);
228
+ const valueSerialized = this.serializeItem(value);
229
+ const ttlMs = this.resolveTtl(options);
230
+ const result = await this.cluster.impl.linsertAfter(mappedKey, pivotSerialized, valueSerialized, ttlMs, source);
231
+ return Number(result);
232
+ }
233
+ /**
234
+ * Removes all occurrences of `value` in the list stored at key.
235
+ *
236
+ * If the list does not contain `value`, or the list does not exist, returns 0.
237
+ *
238
+ * @param key - The cache key.
239
+ * @param value - The value to remove.
240
+ * @returns The number of elements removed.
241
+ * @see https://redis.io/commands/lrem/
242
+ */
243
+ async removeAll(key, value, options) {
244
+ const source = getCurrentRequest();
245
+ const mappedKey = this.mapKey(key);
246
+ const valueSerialized = this.serializeItem(value);
247
+ const ttlMs = this.resolveTtl(options);
248
+ const result = await this.cluster.impl.lremAll(mappedKey, valueSerialized, ttlMs, source);
249
+ return Number(result);
250
+ }
251
+ /**
252
+ * Removes the first `count` occurrences of `value` in the list stored at key,
253
+ * scanning from head to tail.
254
+ *
255
+ * If the list does not contain `value`, or the list does not exist, returns 0.
256
+ *
257
+ * @param key - The cache key.
258
+ * @param count - Maximum number of occurrences to remove.
259
+ * @param value - The value to remove.
260
+ * @returns The number of elements removed.
261
+ * @see https://redis.io/commands/lrem/
262
+ */
263
+ async removeFirst(key, count, value, options) {
264
+ if (count < 0) {
265
+ throw new Error("count must be non-negative");
266
+ }
267
+ const source = getCurrentRequest();
268
+ const mappedKey = this.mapKey(key);
269
+ const valueSerialized = this.serializeItem(value);
270
+ const ttlMs = this.resolveTtl(options);
271
+ const result = await this.cluster.impl.lremFirst(mappedKey, count, valueSerialized, ttlMs, source);
272
+ return Number(result);
273
+ }
274
+ /**
275
+ * Removes the last `count` occurrences of `value` in the list stored at key,
276
+ * scanning from tail to head.
277
+ *
278
+ * If the list does not contain `value`, or the list does not exist, returns 0.
279
+ *
280
+ * @param key - The cache key.
281
+ * @param count - Maximum number of occurrences to remove.
282
+ * @param value - The value to remove.
283
+ * @returns The number of elements removed.
284
+ * @see https://redis.io/commands/lrem/
285
+ */
286
+ async removeLast(key, count, value, options) {
287
+ if (count < 0) {
288
+ throw new Error("count must be non-negative");
289
+ }
290
+ const source = getCurrentRequest();
291
+ const mappedKey = this.mapKey(key);
292
+ const valueSerialized = this.serializeItem(value);
293
+ const ttlMs = this.resolveTtl(options);
294
+ // Negative count means remove from tail to head
295
+ const result = await this.cluster.impl.lremLast(mappedKey, count, valueSerialized, ttlMs, source);
296
+ return Number(result);
297
+ }
298
+ /**
299
+ * Atomically moves an element from the list stored at `src` to the list stored at `dst`.
300
+ *
301
+ * The value moved can be either the head (`srcPos === "left"`) or tail (`srcPos === "right"`)
302
+ * of the list at `src`. Similarly, the value can be placed either at the head (`dstPos === "left"`)
303
+ * or tail (`dstPos === "right"`) of the list at `dst`.
304
+ *
305
+ * If `src` and `dst` are the same list, the value is atomically rotated from one end to the other
306
+ * when `srcPos !== dstPos`, or if `srcPos === dstPos` nothing happens.
307
+ *
308
+ * @param src - Source list key.
309
+ * @param dst - Destination list key.
310
+ * @param srcPos - Position to pop from in the source list.
311
+ * @param dstPos - Position to push to in the destination list.
312
+ * @returns The moved element, or `undefined` if the source list does not exist.
313
+ * @see https://redis.io/commands/lmove/
314
+ */
315
+ async move(src, dst, srcPos, dstPos, options) {
316
+ const source = getCurrentRequest();
317
+ const srcKey = this.mapKey(src);
318
+ const dstKey = this.mapKey(dst);
319
+ const ttlMs = this.resolveTtl(options);
320
+ const result = await this.cluster.impl.lmove(srcKey, dstKey, srcPos, dstPos, ttlMs, source);
321
+ if (result === null || result === undefined) {
322
+ return undefined;
323
+ }
324
+ return this.deserializeItem(result);
325
+ }
326
+ }
327
+ /**
328
+ * StringListKeyspace stores lists of string values.
329
+ *
330
+ * @example
331
+ * ```ts
332
+ * const recentViews = new StringListKeyspace<string>(cluster, {
333
+ * keyPattern: "recent-views/:userId",
334
+ * defaultExpiry: ExpireIn(86400000), // 24 hours
335
+ * });
336
+ *
337
+ * await recentViews.pushLeft("user1", "product-123", "product-456");
338
+ * const views = await recentViews.items("user1");
339
+ * ```
340
+ */
341
+ export class StringListKeyspace extends ListKeyspace {
342
+ constructor(cluster, config) {
343
+ super(cluster, config);
344
+ }
345
+ serializeItem(value) {
346
+ return Buffer.from(value, "utf-8");
347
+ }
348
+ deserializeItem(data) {
349
+ return data.toString("utf-8");
350
+ }
351
+ }
352
+ /**
353
+ * NumberListKeyspace stores lists of numeric values.
354
+ *
355
+ * @example
356
+ * ```ts
357
+ * const scores = new NumberListKeyspace<string>(cluster, {
358
+ * keyPattern: "scores/:gameId",
359
+ * });
360
+ *
361
+ * await scores.pushRight("game1", 100, 200, 300);
362
+ * const allScores = await scores.items("game1");
363
+ * ```
364
+ */
365
+ export class NumberListKeyspace extends ListKeyspace {
366
+ constructor(cluster, config) {
367
+ super(cluster, config);
368
+ }
369
+ serializeItem(value) {
370
+ return Buffer.from(String(value), "utf-8");
371
+ }
372
+ deserializeItem(data) {
373
+ return Number(data.toString("utf-8"));
374
+ }
375
+ }
376
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../storage/cache/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAgC,MAAM,YAAY,CAAC;AAOpE;;;;GAIG;AACH,MAAe,YAAmB,SAAQ,QAAW;IACnD,YAAY,OAAqB,EAAE,MAAyB;QAC1D,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IAKD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAM,EAAE,GAAG,MAAW;QACnC,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,E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AAC,CAAC;IAC7C,CAAC;IAES,eAAe,CAAC,IAAY;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ export { CacheCluster } from "./cluster.js";
2
+ export type { CacheClusterConfig, EvictionPolicy } from "./cluster.js";
3
+ export type { KeyspaceConfig, WriteOptions } from "./keyspace.js";
4
+ export { StringKeyspace, IntKeyspace, FloatKeyspace, StructKeyspace } from "./basic.js";
5
+ export { StringListKeyspace, NumberListKeyspace } from "./list.js";
6
+ export type { ListPosition } from "./list.js";
7
+ export { StringSetKeyspace, NumberSetKeyspace } from "./set.js";
8
+ export { expireIn, expireInSeconds, expireInMinutes, expireInHours, expireDailyAt, neverExpire, keepTTL } from "./expiry.js";
9
+ export type { Expiry } from "./expiry.js";
10
+ export { CacheError, CacheMiss, CacheKeyExists } from "./errors.js";
@@ -0,0 +1,13 @@
1
+ // Cache cluster
2
+ export { CacheCluster } from "./cluster.js";
3
+ // Basic keyspaces
4
+ export { StringKeyspace, IntKeyspace, FloatKeyspace, StructKeyspace } from "./basic.js";
5
+ // List keyspaces
6
+ export { StringListKeyspace, NumberListKeyspace } from "./list.js";
7
+ // Set keyspaces
8
+ export { StringSetKeyspace, NumberSetKeyspace } from "./set.js";
9
+ // Expiry utilities
10
+ export { expireIn, expireInSeconds, expireInMinutes, expireInHours, expireDailyAt, neverExpire, keepTTL } from "./expiry.js";
11
+ // Error types
12
+ export { CacheError, CacheMiss, CacheKeyExists } from "./errors.js";
13
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../storage/cache/mod.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMzC,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,iBAAiB;AACjB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGhE,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,mBAAmB;AACnB,OAAO,EACL,QAAQ,EACR,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,EACR,MAAM,UAAU,CAAC;AAGlB,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,258 @@
1
+ /// <reference types="node" />
2
+ import { CacheCluster } from "./cluster.js";
3
+ import { Keyspace, KeyspaceConfig, WriteOptions } from "./keyspace.js";
4
+ /**
5
+ * Base class for set keyspaces with all set operations.
6
+ * Subclasses provide typed serialization/deserialization.
7
+ * @internal
8
+ */
9
+ declare abstract class SetKeyspace<K, V> extends Keyspace<K> {
10
+ constructor(cluster: CacheCluster, config: KeyspaceConfig<K>);
11
+ protected abstract serializeItem(value: V): Buffer;
12
+ protected abstract deserializeItem(data: Buffer): V;
13
+ /**
14
+ * Adds one or more values to the set stored at key.
15
+ * If the key does not already exist, it is first created as an empty set.
16
+ *
17
+ * @returns The number of values that were added to the set,
18
+ * not including values already present beforehand.
19
+ * @see https://redis.io/commands/sadd/
20
+ */
21
+ add(key: K, ...members: V[]): Promise<number>;
22
+ /**
23
+ * Removes one or more values from the set stored at key.
24
+ * Values not present in the set are ignored.
25
+ * If the key does not already exist, it is a no-op.
26
+ *
27
+ * @returns The number of values that were removed from the set.
28
+ * @see https://redis.io/commands/srem/
29
+ */
30
+ remove(key: K, ...members: V[]): Promise<number>;
31
+ /**
32
+ * Removes a random element from the set stored at key and returns it.
33
+ *
34
+ * @returns The removed member, or `undefined` if the set is empty.
35
+ * @see https://redis.io/commands/spop/
36
+ */
37
+ popOne(key: K, options?: WriteOptions): Promise<V | undefined>;
38
+ /**
39
+ * Removes up to `count` random elements (bounded by the set's size)
40
+ * from the set stored at key and returns them.
41
+ *
42
+ * If the set is empty it returns an empty array.
43
+ *
44
+ * @param key - The cache key.
45
+ * @param count - Number of members to pop.
46
+ * @returns The removed members (may be fewer than `count` if the set is small).
47
+ * @see https://redis.io/commands/spop/
48
+ */
49
+ pop(key: K, count: number, options?: WriteOptions): Promise<V[]>;
50
+ /**
51
+ * Reports whether the set stored at key contains the given value.
52
+ *
53
+ * If the key does not exist it returns `false`.
54
+ *
55
+ * @returns `true` if the member exists in the set, `false` otherwise.
56
+ * @see https://redis.io/commands/sismember/
57
+ */
58
+ contains(key: K, member: V): Promise<boolean>;
59
+ /**
60
+ * Returns the number of elements in the set stored at key.
61
+ *
62
+ * If the key does not exist it returns 0.
63
+ *
64
+ * @returns The set cardinality.
65
+ * @see https://redis.io/commands/scard/
66
+ */
67
+ len(key: K): Promise<number>;
68
+ /**
69
+ * Returns the elements in the set stored at key.
70
+ *
71
+ * If the key does not exist it returns an empty array.
72
+ *
73
+ * @returns All members of the set.
74
+ * @see https://redis.io/commands/smembers/
75
+ */
76
+ items(key: K): Promise<V[]>;
77
+ /**
78
+ * Identical to {@link items} except it returns the values as a `Set`.
79
+ *
80
+ * If the key does not exist it returns an empty `Set`.
81
+ *
82
+ * @returns All members of the set as a `Set`.
83
+ * @see https://redis.io/commands/smembers/
84
+ */
85
+ itemsSet(key: K): Promise<Set<V>>;
86
+ /**
87
+ * Computes the set difference between the first set and all the consecutive sets.
88
+ *
89
+ * Set difference means the values present in the first set that are not present
90
+ * in any of the other sets.
91
+ *
92
+ * Keys that do not exist are considered as empty sets.
93
+ *
94
+ * @param keys - Keys of sets to compute difference for. At least one must be provided.
95
+ * @returns Members in the first set but not in any of the other sets.
96
+ * @throws {Error} If no keys are provided.
97
+ * @see https://redis.io/commands/sdiff/
98
+ */
99
+ diff(...keys: K[]): Promise<V[]>;
100
+ /**
101
+ * Identical to {@link diff} except it returns the values as a `Set`.
102
+ *
103
+ * @see https://redis.io/commands/sdiff/
104
+ */
105
+ diffSet(...keys: K[]): Promise<Set<V>>;
106
+ /**
107
+ * Computes the set difference between keys (like {@link diff}) and stores the result
108
+ * in `destination`.
109
+ *
110
+ * @param destination - Key to store the result.
111
+ * @param keys - Keys of sets to compute difference for.
112
+ * @returns The size of the resulting set.
113
+ * @see https://redis.io/commands/sdiffstore/
114
+ */
115
+ diffStore(destination: K, ...keys: K[]): Promise<number>;
116
+ /**
117
+ * Computes the set intersection between the sets stored at the given keys.
118
+ *
119
+ * Set intersection means the values common to all the provided sets.
120
+ *
121
+ * Keys that do not exist are considered to be empty sets.
122
+ * As a result, if any key is missing the final result is the empty set.
123
+ *
124
+ * @param keys - Keys of sets to compute intersection for. At least one must be provided.
125
+ * @returns Members common to all sets.
126
+ * @throws {Error} If no keys are provided.
127
+ * @see https://redis.io/commands/sinter/
128
+ */
129
+ intersect(...keys: K[]): Promise<V[]>;
130
+ /**
131
+ * Identical to {@link intersect} except it returns the values as a `Set`.
132
+ *
133
+ * @see https://redis.io/commands/sinter/
134
+ */
135
+ intersectSet(...keys: K[]): Promise<Set<V>>;
136
+ /**
137
+ * Computes the set intersection between keys (like {@link intersect}) and stores the result
138
+ * in `destination`.
139
+ *
140
+ * @param destination - Key to store the result.
141
+ * @param keys - Keys of sets to compute intersection for.
142
+ * @returns The size of the resulting set.
143
+ * @see https://redis.io/commands/sinterstore/
144
+ */
145
+ intersectStore(destination: K, ...keys: K[]): Promise<number>;
146
+ /**
147
+ * Computes the set union between the sets stored at the given keys.
148
+ *
149
+ * Set union means the values present in at least one of the provided sets.
150
+ *
151
+ * Keys that do not exist are considered to be empty sets.
152
+ *
153
+ * @param keys - Keys of sets to compute union for. At least one must be provided.
154
+ * @returns Members in any of the provided sets.
155
+ * @throws {Error} If no keys are provided.
156
+ * @see https://redis.io/commands/sunion/
157
+ */
158
+ union(...keys: K[]): Promise<V[]>;
159
+ /**
160
+ * Identical to {@link union} except it returns the values as a `Set`.
161
+ *
162
+ * @see https://redis.io/commands/sunion/
163
+ */
164
+ unionSet(...keys: K[]): Promise<Set<V>>;
165
+ /**
166
+ * Computes the set union between sets (like {@link union}) and stores the result
167
+ * in `destination`.
168
+ *
169
+ * @param destination - Key to store the result.
170
+ * @param keys - Keys of sets to compute union for.
171
+ * @returns The size of the resulting set.
172
+ * @see https://redis.io/commands/sunionstore/
173
+ */
174
+ unionStore(destination: K, ...keys: K[]): Promise<number>;
175
+ /**
176
+ * Returns a random member from the set stored at key without removing it.
177
+ *
178
+ * @returns A random member, or `undefined` if the key does not exist.
179
+ * @see https://redis.io/commands/srandmember/
180
+ */
181
+ sampleOne(key: K): Promise<V | undefined>;
182
+ /**
183
+ * Returns up to `count` distinct random elements from the set stored at key.
184
+ * The same element is never returned multiple times.
185
+ *
186
+ * If the key does not exist it returns an empty array.
187
+ *
188
+ * @param key - The cache key.
189
+ * @param count - Number of distinct members to return.
190
+ * @returns Random members (may be fewer than `count` if the set is small).
191
+ * @see https://redis.io/commands/srandmember/
192
+ */
193
+ sample(key: K, count: number): Promise<V[]>;
194
+ /**
195
+ * Returns `count` random elements from the set stored at key.
196
+ * The same element may be returned multiple times.
197
+ *
198
+ * If the key does not exist it returns an empty array.
199
+ *
200
+ * @param key - The cache key.
201
+ * @param count - Number of members to return (may include duplicates).
202
+ * @returns Random members, possibly with duplicates.
203
+ * @see https://redis.io/commands/srandmember/
204
+ */
205
+ sampleWithReplacement(key: K, count: number): Promise<V[]>;
206
+ /**
207
+ * Atomically moves the given member from the set stored at `src`
208
+ * to the set stored at `dst`.
209
+ *
210
+ * If the element already exists in `dst` it is still removed from `src`.
211
+ *
212
+ * @param src - Source set key.
213
+ * @param dst - Destination set key.
214
+ * @param member - The member to move.
215
+ * @returns `true` if the member was moved, `false` if not found in `src`.
216
+ * @see https://redis.io/commands/smove/
217
+ */
218
+ move(src: K, dst: K, member: V, options?: WriteOptions): Promise<boolean>;
219
+ }
220
+ /**
221
+ * StringSetKeyspace stores sets of unique string values.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * const tags = new StringSetKeyspace<string>(cluster, {
226
+ * keyPattern: "tags/:articleId",
227
+ * });
228
+ *
229
+ * await tags.add("article1", "typescript", "programming", "web");
230
+ * const hasTech = await tags.contains("article1", "typescript");
231
+ * const allTags = await tags.items("article1");
232
+ * const tagSet = await tags.itemsSet("article1");
233
+ * ```
234
+ */
235
+ export declare class StringSetKeyspace<K> extends SetKeyspace<K, string> {
236
+ constructor(cluster: CacheCluster, config: KeyspaceConfig<K>);
237
+ protected serializeItem(value: string): Buffer;
238
+ protected deserializeItem(data: Buffer): string;
239
+ }
240
+ /**
241
+ * NumberSetKeyspace stores sets of unique numeric values.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * const scores = new NumberSetKeyspace<string>(cluster, {
246
+ * keyPattern: "unique-scores/:gameId",
247
+ * });
248
+ *
249
+ * await scores.add("game1", 100, 200, 300);
250
+ * const hasScore = await scores.contains("game1", 100);
251
+ * ```
252
+ */
253
+ export declare class NumberSetKeyspace<K> extends SetKeyspace<K, number> {
254
+ constructor(cluster: CacheCluster, config: KeyspaceConfig<K>);
255
+ protected serializeItem(value: number): Buffer;
256
+ protected deserializeItem(data: Buffer): number;
257
+ }
258
+ export {};