@valkey/valkey-glide-darwin-arm64 1.3.4 → 255.255.255

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 (45) hide show
  1. package/package.json +31 -95
  2. package/README.md +0 -106
  3. package/build-ts/index.d.ts +0 -14
  4. package/build-ts/index.js +0 -34
  5. package/build-ts/index.js.map +0 -1
  6. package/build-ts/src/BaseClient.d.ts +0 -5254
  7. package/build-ts/src/BaseClient.js +0 -6391
  8. package/build-ts/src/BaseClient.js.map +0 -1
  9. package/build-ts/src/Commands.d.ts +0 -1034
  10. package/build-ts/src/Commands.js +0 -2710
  11. package/build-ts/src/Commands.js.map +0 -1
  12. package/build-ts/src/Errors.d.ts +0 -21
  13. package/build-ts/src/Errors.js +0 -43
  14. package/build-ts/src/Errors.js.map +0 -1
  15. package/build-ts/src/GlideClient.d.ts +0 -832
  16. package/build-ts/src/GlideClient.js +0 -940
  17. package/build-ts/src/GlideClient.js.map +0 -1
  18. package/build-ts/src/GlideClusterClient.d.ts +0 -1323
  19. package/build-ts/src/GlideClusterClient.js +0 -1276
  20. package/build-ts/src/GlideClusterClient.js.map +0 -1
  21. package/build-ts/src/Logger.d.ts +0 -32
  22. package/build-ts/src/Logger.js +0 -68
  23. package/build-ts/src/Logger.js.map +0 -1
  24. package/build-ts/src/ProtobufMessage.d.ts +0 -2889
  25. package/build-ts/src/ProtobufMessage.js +0 -8785
  26. package/build-ts/src/ProtobufMessage.js.map +0 -1
  27. package/build-ts/src/Transaction.d.ts +0 -2963
  28. package/build-ts/src/Transaction.js +0 -3388
  29. package/build-ts/src/Transaction.js.map +0 -1
  30. package/build-ts/src/server-modules/GlideFt.d.ts +0 -412
  31. package/build-ts/src/server-modules/GlideFt.js +0 -664
  32. package/build-ts/src/server-modules/GlideFt.js.map +0 -1
  33. package/build-ts/src/server-modules/GlideFtOptions.d.ts +0 -244
  34. package/build-ts/src/server-modules/GlideFtOptions.js +0 -6
  35. package/build-ts/src/server-modules/GlideFtOptions.js.map +0 -1
  36. package/build-ts/src/server-modules/GlideJson.d.ts +0 -1335
  37. package/build-ts/src/server-modules/GlideJson.js +0 -1628
  38. package/build-ts/src/server-modules/GlideJson.js.map +0 -1
  39. package/index.ts +0 -15
  40. package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
  41. package/node_modules/glide-rs/index.d.ts +0 -71
  42. package/node_modules/glide-rs/index.js +0 -317
  43. package/node_modules/glide-rs/package.json +0 -65
  44. package/npm/glide/index.ts +0 -391
  45. package/npm/glide/package.json +0 -67
@@ -1,832 +0,0 @@
1
- /**
2
- * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
- */
4
- import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
5
- import { FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsFullResponse, InfoOptions, LolwutOptions, ScanOptions } from "./Commands";
6
- import { Transaction } from "./Transaction";
7
- export declare namespace GlideClientConfiguration {
8
- /**
9
- * Enum representing pubsub subscription modes.
10
- * @see {@link https://valkey.io/docs/topics/pubsub/|Valkey PubSub Documentation} for more details.
11
- */
12
- enum PubSubChannelModes {
13
- /**
14
- * Use exact channel names.
15
- */
16
- Exact = 0,
17
- /**
18
- * Use channel name patterns.
19
- */
20
- Pattern = 1
21
- }
22
- interface PubSubSubscriptions {
23
- /**
24
- * Channels and patterns by modes.
25
- */
26
- channelsAndPatterns: Partial<Record<PubSubChannelModes, Set<string>>>;
27
- /**
28
- * Optional callback to accept the incoming messages.
29
- */
30
- callback?: (msg: PubSubMsg, context: any) => void;
31
- /**
32
- * Arbitrary context to pass to the callback.
33
- */
34
- context?: any;
35
- }
36
- }
37
- /**
38
- * Configuration options for creating a {@link GlideClient | GlideClient}.
39
- *
40
- * Extends `BaseClientConfiguration` with properties specific to `GlideClient`, such as database selection,
41
- * reconnection strategies, and Pub/Sub subscription settings.
42
- *
43
- * @remarks
44
- * This configuration allows you to tailor the client's behavior when connecting to a standalone Valkey Glide server.
45
- *
46
- * - **Database Selection**: Use `databaseId` to specify which logical database to connect to.
47
- * - **Reconnection Strategy**: Customize how the client should attempt reconnections using `connectionBackoff`.
48
- * - `numberOfRetries`: The maximum number of retry attempts with increasing delays.
49
- * - After this limit is reached, the retry interval becomes constant.
50
- * - `factor`: A multiplier applied to the base delay between retries (e.g., `500` means a 500ms base delay).
51
- * - `exponentBase`: The exponential growth factor for delays (e.g., `2` means the delay doubles with each retry).
52
- * - **Pub/Sub Subscriptions**: Predefine Pub/Sub channels and patterns to subscribe to upon connection establishment.
53
- *
54
- * @example
55
- * ```typescript
56
- * const config: GlideClientConfiguration = {
57
- * databaseId: 1,
58
- * connectionBackoff: {
59
- * numberOfRetries: 10, // Maximum retries before delay becomes constant
60
- * factor: 500, // Base delay in milliseconds
61
- * exponentBase: 2, // Delay doubles with each retry (2^N)
62
- * },
63
- * pubsubSubscriptions: {
64
- * channelsAndPatterns: {
65
- * [GlideClientConfiguration.PubSubChannelModes.Pattern]: new Set(['news.*']),
66
- * },
67
- * callback: (msg) => {
68
- * console.log(`Received message on ${msg.channel}:`, msg.payload);
69
- * },
70
- * },
71
- * };
72
- * ```
73
- */
74
- export type GlideClientConfiguration = BaseClientConfiguration & {
75
- /**
76
- * index of the logical database to connect to.
77
- */
78
- databaseId?: number;
79
- /**
80
- * Strategy used to determine how and when to reconnect, in case of connection failures.
81
- * The time between attempts grows exponentially, to the formula rand(0 .. factor * (exponentBase ^ N)), where N is the number of failed attempts.
82
- * The client will attempt to reconnect indefinitely. Once the maximum value is reached, that will remain the time between retry attempts until a
83
- * reconnect attempt is succesful.
84
- * If not set, a default backoff strategy will be used.
85
- */
86
- connectionBackoff?: {
87
- /**
88
- * Number of retry attempts that the client should perform when disconnected from the server, where the time between retries increases.
89
- * Once the retries have reached the maximum value, the time between retries will remain constant until a reconnect attempt is succesful.
90
- * Value must be an integer.
91
- */
92
- numberOfRetries: number;
93
- /**
94
- * The multiplier that will be applied to the waiting time between each retry.
95
- * Value must be an integer.
96
- */
97
- factor: number;
98
- /**
99
- * The exponent base configured for the strategy.
100
- * Value must be an integer.
101
- */
102
- exponentBase: number;
103
- };
104
- /**
105
- * PubSub subscriptions to be used for the client.
106
- * Will be applied via SUBSCRIBE/PSUBSCRIBE commands during connection establishment.
107
- */
108
- pubsubSubscriptions?: GlideClientConfiguration.PubSubSubscriptions;
109
- /**
110
- * Advanced configuration settings for the client.
111
- */
112
- advancedConfiguration?: AdvancedGlideClientConfiguration;
113
- };
114
- /**
115
- * Represents advanced configuration settings for creating a {@link GlideClient | GlideClient} used in {@link GlideClientConfiguration | GlideClientConfiguration}.
116
- *
117
- *
118
- * @example
119
- * ```typescript
120
- * const config: AdvancedGlideClientConfiguration = {
121
- * connectionTimeout: 500, // Set the connection timeout to 500ms
122
- * };
123
- * ```
124
- */
125
- export type AdvancedGlideClientConfiguration = AdvancedBaseClientConfiguration & {};
126
- /**
127
- * Client used for connection to standalone servers.
128
- *
129
- * @see For full documentation refer to {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#standalone|Valkey Glide Wiki}.
130
- */
131
- export declare class GlideClient extends BaseClient {
132
- /**
133
- * Creates a new `GlideClient` instance and establishes a connection to a standalone Valkey Glide server.
134
- *
135
- * @param options - The configuration options for the client, including server addresses, authentication credentials, TLS settings, database selection, reconnection strategy, and Pub/Sub subscriptions.
136
- * @returns A promise that resolves to a connected `GlideClient` instance.
137
- *
138
- * @remarks
139
- * Use this static method to create and connect a `GlideClient` to a standalone Valkey Glide server. The client will automatically handle connection establishment, including any authentication and TLS configurations.
140
- *
141
- * @example
142
- * ```typescript
143
- * // Connecting to a Standalone Server
144
- * import { GlideClient, GlideClientConfiguration } from '@valkey/valkey-glide';
145
- *
146
- * const client = await GlideClient.createClient({
147
- * addresses: [
148
- * { host: 'primary.example.com', port: 6379 },
149
- * { host: 'replica1.example.com', port: 6379 },
150
- * ],
151
- * databaseId: 1,
152
- * credentials: {
153
- * username: 'user1',
154
- * password: 'passwordA',
155
- * },
156
- * useTLS: true,
157
- * connectionBackoff: {
158
- * numberOfRetries: 5,
159
- * factor: 1000,
160
- * exponentBase: 2,
161
- * },
162
- * pubsubSubscriptions: {
163
- * channelsAndPatterns: {
164
- * [GlideClientConfiguration.PubSubChannelModes.Exact]: new Set(['updates']),
165
- * },
166
- * callback: (msg) => {
167
- * console.log(`Received message: ${msg.payload}`);
168
- * },
169
- * },
170
- * });
171
- * ```
172
- *
173
- * @remarks
174
- * - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
175
- * - **TLS**: If `useTLS` is set to `true`, the client will establish a secure connection using TLS.
176
- * - **Reconnection Strategy**: The `connectionBackoff` settings define how the client will attempt to reconnect in case of disconnections.
177
- * - **Pub/Sub Subscriptions**: Any channels or patterns specified in `pubsubSubscriptions` will be subscribed to upon connection.
178
- */
179
- static createClient(options: GlideClientConfiguration): Promise<GlideClient>;
180
- /**
181
- * Execute a transaction by processing the queued commands.
182
- *
183
- * @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey Glide Wiki} for details on Valkey Transactions.
184
- *
185
- * @param transaction - A {@link Transaction} object containing a list of commands to be executed.
186
- * @param options - (Optional) See {@link DecoderOption}.
187
- * @returns A list of results corresponding to the execution of each command in the transaction.
188
- * If a command returns a value, it will be included in the list. If a command doesn't return a value,
189
- * the list entry will be `null`.
190
- * If the transaction failed due to a `WATCH` command, `exec` will return `null`.
191
- */
192
- exec(transaction: Transaction, options?: DecoderOption): Promise<GlideReturnType[] | null>;
193
- /** Executes a single command, without checking inputs. Every part of the command, including subcommands,
194
- * should be added as a separate value in args.
195
- *
196
- * Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
197
- *
198
- * @see {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command|Valkey Glide Wiki} for details on the restrictions and limitations of the custom command API.
199
- *
200
- * @param args - A list including the command name and arguments for the custom command.
201
- * @param options - (Optional) See {@link DecoderOption}.
202
- * @returns The executed custom command return value.
203
- *
204
- * @example
205
- * ```typescript
206
- * // Example usage of customCommand method to retrieve pub/sub clients
207
- * const result = await client.customCommand(["CLIENT", "LIST", "TYPE", "PUBSUB"]);
208
- * console.log(result); // Output: Returns a list of all pub/sub clients
209
- * ```
210
- */
211
- customCommand(args: GlideString[], options?: DecoderOption): Promise<GlideReturnType>;
212
- /**
213
- * Pings the server.
214
- *
215
- * @see {@link https://valkey.io/commands/ping/|valkey.io} for details.
216
- *
217
- * @param options - (Optional) Additional parameters:
218
- * - (Optional) `message` : a message to include in the `PING` command.
219
- * + If not provided, the server will respond with `"PONG"`.
220
- * + If provided, the server will respond with a copy of the message.
221
- * - (Optional) `decoder`: see {@link DecoderOption}.
222
- * @returns `"PONG"` if `message` is not provided, otherwise return a copy of `message`.
223
- *
224
- * @example
225
- * ```typescript
226
- * // Example usage of ping method without any message
227
- * const result = await client.ping();
228
- * console.log(result); // Output: 'PONG'
229
- * ```
230
- *
231
- * @example
232
- * ```typescript
233
- * // Example usage of ping method with a message
234
- * const result = await client.ping("Hello");
235
- * console.log(result); // Output: 'Hello'
236
- * ```
237
- */
238
- ping(options?: {
239
- message?: GlideString;
240
- } & DecoderOption): Promise<GlideString>;
241
- /**
242
- * Gets information and statistics about the server.
243
- *
244
- * @see {@link https://valkey.io/commands/info/|valkey.io} for details.
245
- *
246
- * @param sections - (Optional) A list of {@link InfoOptions} values specifying which sections of information to retrieve.
247
- * When no parameter is provided, {@link InfoOptions.Default|Default} is assumed.
248
- * @returns A string containing the information for the sections requested.
249
- */
250
- info(sections?: InfoOptions[]): Promise<string>;
251
- /**
252
- * Changes the currently selected database.
253
- *
254
- * @see {@link https://valkey.io/commands/select/|valkey.io} for details.
255
- *
256
- * @param index - The index of the database to select.
257
- * @returns A simple `"OK"` response.
258
- *
259
- * @example
260
- * ```typescript
261
- * // Example usage of select method
262
- * const result = await client.select(2);
263
- * console.log(result); // Output: 'OK'
264
- * ```
265
- */
266
- select(index: number): Promise<"OK">;
267
- /**
268
- * Gets the name of the primary's connection.
269
- *
270
- * @see {@link https://valkey.io/commands/client-getname/|valkey.io} for more details.
271
- *
272
- * @param options - (Optional) See {@link DecoderOption}.
273
- * @returns The name of the client connection as a string if a name is set, or `null` if no name is assigned.
274
- *
275
- * @example
276
- * ```typescript
277
- * // Example usage of client_getname method
278
- * const result = await client.client_getname();
279
- * console.log(result); // Output: 'Client Name'
280
- * ```
281
- */
282
- clientGetName(options?: DecoderOption): Promise<GlideString | null>;
283
- /**
284
- * Rewrites the configuration file with the current configuration.
285
- *
286
- * @see {@link https://valkey.io/commands/config-rewrite/|valkey.io} for details.
287
- *
288
- * @returns "OK" when the configuration was rewritten properly. Otherwise, an error is thrown.
289
- *
290
- * @example
291
- * ```typescript
292
- * // Example usage of configRewrite command
293
- * const result = await client.configRewrite();
294
- * console.log(result); // Output: 'OK'
295
- * ```
296
- */
297
- configRewrite(): Promise<"OK">;
298
- /**
299
- * Resets the statistics reported by the server using the `INFO` and `LATENCY HISTOGRAM` commands.
300
- *
301
- * @see {@link https://valkey.io/commands/config-resetstat/|valkey.io} for details.
302
- *
303
- * @returns always "OK".
304
- *
305
- * @example
306
- * ```typescript
307
- * // Example usage of configResetStat command
308
- * const result = await client.configResetStat();
309
- * console.log(result); // Output: 'OK'
310
- * ```
311
- */
312
- configResetStat(): Promise<"OK">;
313
- /**
314
- * Returns the current connection ID.
315
- *
316
- * @see {@link https://valkey.io/commands/client-id/|valkey.io} for details.
317
- *
318
- * @returns The ID of the connection.
319
- *
320
- * @example
321
- * ```typescript
322
- * const result = await client.clientId();
323
- * console.log("Connection id: " + result);
324
- * ```
325
- */
326
- clientId(): Promise<number>;
327
- /**
328
- * Reads the configuration parameters of the running server.
329
- * Starting from server version 7, command supports multiple parameters.
330
- *
331
- * @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
332
- *
333
- * @param parameters - A list of configuration parameter names to retrieve values for.
334
- * @param options - (Optional) See {@link DecoderOption}.
335
- *
336
- * @returns A map of values corresponding to the configuration parameters.
337
- *
338
- * @example
339
- * ```typescript
340
- * // Example usage of configGet method with multiple configuration parameters
341
- * const result = await client.configGet(["timeout", "maxmemory"]);
342
- * console.log(result); // Output: {'timeout': '1000', 'maxmemory': '1GB'}
343
- * ```
344
- */
345
- configGet(parameters: string[], options?: DecoderOption): Promise<Record<string, GlideString>>;
346
- /**
347
- * Sets configuration parameters to the specified values.
348
- * Starting from server version 7, command supports multiple parameters.
349
- *
350
- * @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
351
- * @param parameters - A map consisting of configuration parameters and their respective values to set.
352
- * @returns `"OK"` when the configuration was set properly. Otherwise an error is thrown.
353
- *
354
- * @example
355
- * ```typescript
356
- * // Example usage of configSet method to set multiple configuration parameters
357
- * const result = await client.configSet({ timeout: "1000", maxmemory, "1GB" });
358
- * console.log(result); // Output: 'OK'
359
- * ```
360
- */
361
- configSet(parameters: Record<string, GlideString>): Promise<"OK">;
362
- /**
363
- * Echoes the provided `message` back.
364
- *
365
- * @see {@link https://valkey.io/commands/echo|valkey.io} for more details.
366
- *
367
- * @param message - The message to be echoed back.
368
- * @param options - (Optional) See {@link DecoderOption}.
369
- * @returns The provided `message`.
370
- *
371
- * @example
372
- * ```typescript
373
- * // Example usage of the echo command
374
- * const echoedMessage = await client.echo("valkey-glide");
375
- * console.log(echoedMessage); // Output: 'valkey-glide'
376
- * ```
377
- */
378
- echo(message: GlideString, options?: DecoderOption): Promise<GlideString>;
379
- /**
380
- * Returns the server time.
381
- *
382
- * @see {@link https://valkey.io/commands/time/|valkey.io} for details.
383
- *
384
- * @returns The current server time as an `array` with two items:
385
- * - A Unix timestamp,
386
- * - The amount of microseconds already elapsed in the current second.
387
- *
388
- * @example
389
- * ```typescript
390
- * console.log(await client.time()); // Output: ['1710925775', '913580']
391
- * ```
392
- */
393
- time(): Promise<[string, string]>;
394
- /**
395
- * Copies the value stored at the `source` to the `destination` key. If `destinationDB` is specified,
396
- * the value will be copied to the database specified, otherwise the current database will be used.
397
- * When `replace` is true, removes the `destination` key first if it already exists, otherwise performs
398
- * no action.
399
- *
400
- * @see {@link https://valkey.io/commands/copy/|valkey.io} for more details.
401
- * @remarks Since Valkey version 6.2.0.
402
- *
403
- * @param source - The key to the source value.
404
- * @param destination - The key where the value should be copied to.
405
- * @param options - (Optional) Additional parameters:
406
- * - (Optional) `destinationDB`: the alternative logical database index for the destination key.
407
- * If not provided, the current database will be used.
408
- * - (Optional) `replace`: if `true`, the `destination` key should be removed before copying the
409
- * value to it. If not provided, no action will be performed if the key already exists.
410
- * @returns `true` if `source` was copied, `false` if the `source` was not copied.
411
- *
412
- * @example
413
- * ```typescript
414
- * const result = await client.copy("set1", "set2");
415
- * console.log(result); // Output: true - "set1" was copied to "set2".
416
- * ```
417
- * ```typescript
418
- * const result = await client.copy("set1", "set2", { replace: true });
419
- * console.log(result); // Output: true - "set1" was copied to "set2".
420
- * ```
421
- * ```typescript
422
- * const result = await client.copy("set1", "set2", { destinationDB: 1, replace: false });
423
- * console.log(result); // Output: true - "set1" was copied to "set2".
424
- * ```
425
- */
426
- copy(source: GlideString, destination: GlideString, options?: {
427
- destinationDB?: number;
428
- replace?: boolean;
429
- }): Promise<boolean>;
430
- /**
431
- * Move `key` from the currently selected database to the database specified by `dbIndex`.
432
- *
433
- * @see {@link https://valkey.io/commands/move/|valkey.io} for more details.
434
- *
435
- * @param key - The key to move.
436
- * @param dbIndex - The index of the database to move `key` to.
437
- * @returns `true` if `key` was moved, or `false` if the `key` already exists in the destination
438
- * database or does not exist in the source database.
439
- *
440
- * @example
441
- * ```typescript
442
- * const result = await client.move("key", 1);
443
- * console.log(result); // Output: true
444
- * ```
445
- */
446
- move(key: GlideString, dbIndex: number): Promise<boolean>;
447
- /**
448
- * Displays a piece of generative computer art and the server version.
449
- *
450
- * @see {@link https://valkey.io/commands/lolwut/|valkey.io} for more details.
451
- *
452
- * @param options - (Optional) The LOLWUT options - see {@link LolwutOptions}.
453
- * @returns A piece of generative computer art along with the current server version.
454
- *
455
- * @example
456
- * ```typescript
457
- * const response = await client.lolwut({ version: 6, parameters: [40, 20] });
458
- * console.log(response); // Output: "Valkey ver. 7.2.3" - Indicates the current server version.
459
- * ```
460
- */
461
- lolwut(options?: LolwutOptions): Promise<string>;
462
- /**
463
- * Deletes a library and all its functions.
464
- *
465
- * @see {@link https://valkey.io/commands/function-delete/|valkey.io} for details.
466
- * @remarks Since Valkey version 7.0.0.
467
- *
468
- * @param libraryCode - The library name to delete.
469
- * @returns A simple `"OK"` response.
470
- *
471
- * @example
472
- * ```typescript
473
- * const result = await client.functionDelete("libName");
474
- * console.log(result); // Output: 'OK'
475
- * ```
476
- */
477
- functionDelete(libraryCode: GlideString): Promise<"OK">;
478
- /**
479
- * Loads a library to Valkey.
480
- *
481
- * @see {@link https://valkey.io/commands/function-load/|valkey.io} for details.
482
- * @remarks Since Valkey version 7.0.0.
483
- *
484
- * @param libraryCode - The source code that implements the library.
485
- * @param options - (Optional) Additional parameters:
486
- * - (Optional) `replace`: Whether the given library should overwrite a library with the same name if it
487
- * already exists.
488
- * - (Optional) `decoder`: see {@link DecoderOption}.
489
- * @returns The library name that was loaded.
490
- *
491
- * @example
492
- * ```typescript
493
- * const code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)";
494
- * const result = await client.functionLoad(code, { replace: true });
495
- * console.log(result); // Output: 'mylib'
496
- * ```
497
- */
498
- functionLoad(libraryCode: GlideString, options?: {
499
- replace?: boolean;
500
- } & DecoderOption): Promise<GlideString>;
501
- /**
502
- * Deletes all function libraries.
503
- *
504
- * @see {@link https://valkey.io/commands/function-flush/|valkey.io} for details.
505
- * @remarks Since Valkey version 7.0.0.
506
- *
507
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
508
- * @returns A simple `"OK"` response.
509
- *
510
- * @example
511
- * ```typescript
512
- * const result = await client.functionFlush(FlushMode.SYNC);
513
- * console.log(result); // Output: 'OK'
514
- * ```
515
- */
516
- functionFlush(mode?: FlushMode): Promise<"OK">;
517
- /**
518
- * Returns information about the functions and libraries.
519
- *
520
- * @see {@link https://valkey.io/commands/function-list/|valkey.io} for details.
521
- * @remarks Since Valkey version 7.0.0.
522
- *
523
- * @param options - (Optional) See {@link FunctionListOptions} and {@link DecoderOption}.
524
- * @returns Info about all or selected libraries and their functions in {@link FunctionListResponse} format.
525
- *
526
- * @example
527
- * ```typescript
528
- * // Request info for specific library including the source code
529
- * const result1 = await client.functionList({ libNamePattern: "myLib*", withCode: true });
530
- * // Request info for all libraries
531
- * const result2 = await client.functionList();
532
- * console.log(result2); // Output:
533
- * // [{
534
- * // "library_name": "myLib5_backup",
535
- * // "engine": "LUA",
536
- * // "functions": [{
537
- * // "name": "myfunc",
538
- * // "description": null,
539
- * // "flags": [ "no-writes" ],
540
- * // }],
541
- * // "library_code": "#!lua name=myLib5_backup \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
542
- * // }]
543
- * ```
544
- */
545
- functionList(options?: FunctionListOptions & DecoderOption): Promise<FunctionListResponse>;
546
- /**
547
- * Returns information about the function that's currently running and information about the
548
- * available execution engines.
549
- *
550
- * FUNCTION STATS runs on all nodes of the server, including primary and replicas.
551
- * The response includes a mapping from node address to the command response for that node.
552
- *
553
- * @see {@link https://valkey.io/commands/function-stats/|valkey.io} for details.
554
- * @remarks Since Valkey version 7.0.0.
555
- *
556
- * @param options - (Optional) See {@link DecoderOption}.
557
- * @returns A Record where the key is the node address and the value is a Record with two keys:
558
- * - `"running_script"`: Information about the running script, or `null` if no script is running.
559
- * - `"engines"`: Information about available engines and their stats.
560
- * - see example for more details.
561
- * @example
562
- * ```typescript
563
- * const response = await client.functionStats();
564
- * console.log(response); // Example output:
565
- * // {
566
- * // "127.0.0.1:6379": { // Response from the primary node
567
- * // "running_script": {
568
- * // "name": "foo",
569
- * // "command": ["FCALL", "foo", "0", "hello"],
570
- * // "duration_ms": 7758
571
- * // },
572
- * // "engines": {
573
- * // "LUA": {
574
- * // "libraries_count": 1,
575
- * // "functions_count": 1
576
- * // }
577
- * // }
578
- * // },
579
- * // "127.0.0.1:6380": { // Response from a replica node
580
- * // "running_script": null,
581
- * // "engines": {
582
- * // "LUA": {
583
- * // "libraries_count": 1,
584
- * // "functions_count": 1
585
- * // }
586
- * // }
587
- * // }
588
- * // }
589
- * ```
590
- */
591
- functionStats(options?: DecoderOption): Promise<FunctionStatsFullResponse>;
592
- /**
593
- * Kills a function that is currently executing.
594
- * `FUNCTION KILL` terminates read-only functions only.
595
- * `FUNCTION KILL` runs on all nodes of the server, including primary and replicas.
596
- *
597
- * @see {@link https://valkey.io/commands/function-kill/|valkey.io} for details.
598
- * @remarks Since Valkey version 7.0.0.
599
- *
600
- * @returns `"OK"` if function is terminated. Otherwise, throws an error.
601
- * @example
602
- * ```typescript
603
- * await client.functionKill();
604
- * ```
605
- */
606
- functionKill(): Promise<"OK">;
607
- /**
608
- * Returns the serialized payload of all loaded libraries.
609
- *
610
- * @see {@link https://valkey.io/commands/function-dump/|valkey.io} for details.
611
- * @remarks Since Valkey version 7.0.0.
612
- *
613
- * @returns The serialized payload of all loaded libraries.
614
- *
615
- * @example
616
- * ```typescript
617
- * const data = await client.functionDump();
618
- * // data can be used to restore loaded functions on any Valkey instance
619
- * ```
620
- */
621
- functionDump(): Promise<Buffer>;
622
- /**
623
- * Restores libraries from the serialized payload returned by {@link functionDump}.
624
- *
625
- * @see {@link https://valkey.io/commands/function-restore/|valkey.io} for details.
626
- * @remarks Since Valkey version 7.0.0.
627
- *
628
- * @param payload - The serialized data from {@link functionDump}.
629
- * @param policy - (Optional) A policy for handling existing libraries, see {@link FunctionRestorePolicy}.
630
- * {@link FunctionRestorePolicy.APPEND} is used by default.
631
- * @returns `"OK"`.
632
- *
633
- * @example
634
- * ```typescript
635
- * await client.functionRestore(data, FunctionRestorePolicy.FLUSH);
636
- * ```
637
- */
638
- functionRestore(payload: Buffer, policy?: FunctionRestorePolicy): Promise<"OK">;
639
- /**
640
- * Deletes all the keys of all the existing databases. This command never fails.
641
- *
642
- * @see {@link https://valkey.io/commands/flushall/|valkey.io} for more details.
643
- *
644
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
645
- * @returns `"OK"`.
646
- *
647
- * @example
648
- * ```typescript
649
- * const result = await client.flushall(FlushMode.SYNC);
650
- * console.log(result); // Output: 'OK'
651
- * ```
652
- */
653
- flushall(mode?: FlushMode): Promise<"OK">;
654
- /**
655
- * Deletes all the keys of the currently selected database. This command never fails.
656
- *
657
- * @see {@link https://valkey.io/commands/flushdb/|valkey.io} for more details.
658
- *
659
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
660
- * @returns `"OK"`.
661
- *
662
- * @example
663
- * ```typescript
664
- * const result = await client.flushdb(FlushMode.SYNC);
665
- * console.log(result); // Output: 'OK'
666
- * ```
667
- */
668
- flushdb(mode?: FlushMode): Promise<"OK">;
669
- /**
670
- * Returns the number of keys in the currently selected database.
671
- *
672
- * @see {@link https://valkey.io/commands/dbsize/|valkey.io} for more details.
673
- *
674
- * @returns The number of keys in the currently selected database.
675
- *
676
- * @example
677
- * ```typescript
678
- * const numKeys = await client.dbsize();
679
- * console.log("Number of keys in the current database: ", numKeys);
680
- * ```
681
- */
682
- dbsize(): Promise<number>;
683
- /** Publish a message on pubsub channel.
684
- *
685
- * @see {@link https://valkey.io/commands/publish/|valkey.io} for more details.
686
- *
687
- * @param message - Message to publish.
688
- * @param channel - Channel to publish the message on.
689
- * @returns - Number of subscriptions in primary node that received the message.
690
- * Note that this value does not include subscriptions that configured on replicas.
691
- *
692
- * @example
693
- * ```typescript
694
- * // Example usage of publish command
695
- * const result = await client.publish("Hi all!", "global-channel");
696
- * console.log(result); // Output: 1 - This message was posted to 1 subscription which is configured on primary node
697
- * ```
698
- */
699
- publish(message: GlideString, channel: GlideString): Promise<number>;
700
- /**
701
- * Returns `UNIX TIME` of the last DB save timestamp or startup timestamp if no save
702
- * was made since then.
703
- *
704
- * @see {@link https://valkey.io/commands/lastsave/|valkey.io} for more details.
705
- *
706
- * @returns `UNIX TIME` of the last DB save executed with success.
707
- *
708
- * @example
709
- * ```typescript
710
- * const timestamp = await client.lastsave();
711
- * console.log("Last DB save was done at " + timestamp);
712
- * ```
713
- */
714
- lastsave(): Promise<number>;
715
- /**
716
- * Returns a random existing key name from the currently selected database.
717
- *
718
- * @see {@link https://valkey.io/commands/randomkey/|valkey.io} for more details.
719
- * @param options - (Optional) See {@link DecoderOption}.
720
- * @returns A random existing key name from the currently selected database.
721
- *
722
- * @example
723
- * ```typescript
724
- * const result = await client.randomKey();
725
- * console.log(result); // Output: "key12" - "key12" is a random existing key name from the currently selected database.
726
- * ```
727
- */
728
- randomKey(options?: DecoderOption): Promise<GlideString | null>;
729
- /**
730
- * Flushes all the previously watched keys for a transaction. Executing a transaction will
731
- * automatically flush all previously watched keys.
732
- *
733
- * @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey Glide Wiki} for more details.
734
- *
735
- * @returns A simple `"OK"` response.
736
- *
737
- * @example
738
- * ```typescript
739
- * let response = await client.watch(["sampleKey"]);
740
- * console.log(response); // Output: "OK"
741
- * response = await client.unwatch();
742
- * console.log(response); // Output: "OK"
743
- * ```
744
- */
745
- unwatch(): Promise<"OK">;
746
- /**
747
- * Checks existence of scripts in the script cache by their SHA1 digest.
748
- *
749
- * @see {@link https://valkey.io/commands/script-exists/|valkey.io} for more details.
750
- *
751
- * @param sha1s - List of SHA1 digests of the scripts to check.
752
- * @returns A list of boolean values indicating the existence of each script.
753
- *
754
- * @example
755
- * ```typescript
756
- * console result = await client.scriptExists(["sha1_digest1", "sha1_digest2"]);
757
- * console.log(result); // Output: [true, false]
758
- * ```
759
- */
760
- scriptExists(sha1s: GlideString[]): Promise<boolean[]>;
761
- /**
762
- * Flushes the Lua scripts cache.
763
- *
764
- * @see {@link https://valkey.io/commands/script-flush/|valkey.io} for more details.
765
- *
766
- * @param mode - (Optional) The flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
767
- * @returns A simple `"OK"` response.
768
- *
769
- * @example
770
- * ```typescript
771
- * console result = await client.scriptFlush(FlushMode.SYNC);
772
- * console.log(result); // Output: "OK"
773
- * ```
774
- */
775
- scriptFlush(mode?: FlushMode): Promise<"OK">;
776
- /**
777
- * Kills the currently executing Lua script, assuming no write operation was yet performed by the script.
778
- *
779
- * @see {@link https://valkey.io/commands/script-kill/|valkey.io} for more details.
780
- *
781
- * @returns A simple `"OK"` response.
782
- *
783
- * @example
784
- * ```typescript
785
- * console result = await client.scriptKill();
786
- * console.log(result); // Output: "OK"
787
- * ```
788
- */
789
- scriptKill(): Promise<"OK">;
790
- /**
791
- * Incrementally iterate over a collection of keys.
792
- * `SCAN` is a cursor based iterator. This means that at every call of the method,
793
- * the server returns an updated cursor that the user needs to use as the cursor argument in the next call.
794
- * An iteration starts when the cursor is set to "0", and terminates when the cursor returned by the server is "0".
795
- *
796
- * A full iteration always retrieves all the elements that were present
797
- * in the collection from the start to the end of a full iteration.
798
- * Elements that were not constantly present in the collection during a full iteration, may be returned or not.
799
- *
800
- * @see {@link https://valkey.io/commands/scan|valkey.io} for more details.
801
- *
802
- * @param cursor - The `cursor` used for iteration. For the first iteration, the cursor should be set to "0".
803
- * Using a non-zero cursor in the first iteration,
804
- * or an invalid cursor at any iteration, will lead to undefined results.
805
- * Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
806
- * return the same elements multiple times.
807
- * If the the db has changed, it may result in undefined behavior.
808
- * @param options - (Optional) The options to use for the scan operation, see {@link ScanOptions} and {@link DecoderOption}.
809
- * @returns A List containing the next cursor value and a list of keys,
810
- * formatted as [cursor, [key1, key2, ...]]
811
- *
812
- * @example
813
- * ```typescript
814
- * // Example usage of scan method
815
- * let result = await client.scan('0');
816
- * console.log(result); // Output: ['17', ['key1', 'key2', 'key3', 'key4', 'key5', 'set1', 'set2', 'set3']]
817
- * let firstCursorResult = result[0];
818
- * result = await client.scan(firstCursorResult);
819
- * console.log(result); // Output: ['349', ['key4', 'key5', 'set1', 'hash1', 'zset1', 'list1', 'list2',
820
- * // 'list3', 'zset2', 'zset3', 'zset4', 'zset5', 'zset6']]
821
- * result = await client.scan(result[0]);
822
- * console.log(result); // Output: ['0', ['key6', 'key7']]
823
- *
824
- * result = await client.scan(firstCursorResult, {match: 'key*', count: 2});
825
- * console.log(result); // Output: ['6', ['key4', 'key5']]
826
- *
827
- * result = await client.scan("0", {type: ObjectType.Set});
828
- * console.log(result); // Output: ['362', ['set1', 'set2', 'set3']]
829
- * ```
830
- */
831
- scan(cursor: GlideString, options?: ScanOptions & DecoderOption): Promise<[GlideString, GlideString[]]>;
832
- }