@valkey/valkey-glide-darwin-x64 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.
- package/package.json +31 -95
- package/README.md +0 -106
- package/build-ts/index.d.ts +0 -14
- package/build-ts/index.js +0 -34
- package/build-ts/index.js.map +0 -1
- package/build-ts/src/BaseClient.d.ts +0 -5254
- package/build-ts/src/BaseClient.js +0 -6391
- package/build-ts/src/BaseClient.js.map +0 -1
- package/build-ts/src/Commands.d.ts +0 -1034
- package/build-ts/src/Commands.js +0 -2710
- package/build-ts/src/Commands.js.map +0 -1
- package/build-ts/src/Errors.d.ts +0 -21
- package/build-ts/src/Errors.js +0 -43
- package/build-ts/src/Errors.js.map +0 -1
- package/build-ts/src/GlideClient.d.ts +0 -832
- package/build-ts/src/GlideClient.js +0 -940
- package/build-ts/src/GlideClient.js.map +0 -1
- package/build-ts/src/GlideClusterClient.d.ts +0 -1323
- package/build-ts/src/GlideClusterClient.js +0 -1276
- package/build-ts/src/GlideClusterClient.js.map +0 -1
- package/build-ts/src/Logger.d.ts +0 -32
- package/build-ts/src/Logger.js +0 -68
- package/build-ts/src/Logger.js.map +0 -1
- package/build-ts/src/ProtobufMessage.d.ts +0 -2889
- package/build-ts/src/ProtobufMessage.js +0 -8785
- package/build-ts/src/ProtobufMessage.js.map +0 -1
- package/build-ts/src/Transaction.d.ts +0 -2963
- package/build-ts/src/Transaction.js +0 -3388
- package/build-ts/src/Transaction.js.map +0 -1
- package/build-ts/src/server-modules/GlideFt.d.ts +0 -412
- package/build-ts/src/server-modules/GlideFt.js +0 -664
- package/build-ts/src/server-modules/GlideFt.js.map +0 -1
- package/build-ts/src/server-modules/GlideFtOptions.d.ts +0 -244
- package/build-ts/src/server-modules/GlideFtOptions.js +0 -6
- package/build-ts/src/server-modules/GlideFtOptions.js.map +0 -1
- package/build-ts/src/server-modules/GlideJson.d.ts +0 -1335
- package/build-ts/src/server-modules/GlideJson.js +0 -1628
- package/build-ts/src/server-modules/GlideJson.js.map +0 -1
- package/index.ts +0 -15
- package/node_modules/glide-rs/glide-rs.darwin-x64.node +0 -0
- package/node_modules/glide-rs/index.d.ts +0 -71
- package/node_modules/glide-rs/index.js +0 -317
- package/node_modules/glide-rs/package.json +0 -65
- package/npm/glide/index.ts +0 -391
- package/npm/glide/package.json +0 -67
|
@@ -1,1323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
3
|
-
*/
|
|
4
|
-
import { ClusterScanCursor, Script } from "glide-rs";
|
|
5
|
-
import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg } from "./BaseClient";
|
|
6
|
-
import { ClusterScanOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsSingleResponse, InfoOptions, LolwutOptions } from "./Commands";
|
|
7
|
-
import { ClusterTransaction } from "./Transaction";
|
|
8
|
-
/** An extension to command option types with {@link Routes}. */
|
|
9
|
-
export interface RouteOption {
|
|
10
|
-
/**
|
|
11
|
-
* Specifies the routing configuration for the command.
|
|
12
|
-
* The client will route the command to the nodes defined by `route`.
|
|
13
|
-
*/
|
|
14
|
-
route?: Routes;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Represents a manually configured interval for periodic checks.
|
|
18
|
-
*/
|
|
19
|
-
export interface PeriodicChecksManualInterval {
|
|
20
|
-
/**
|
|
21
|
-
* The duration in seconds for the interval between periodic checks.
|
|
22
|
-
*/
|
|
23
|
-
duration_in_sec: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Periodic checks configuration.
|
|
27
|
-
*/
|
|
28
|
-
export type PeriodicChecks =
|
|
29
|
-
/**
|
|
30
|
-
* Enables the periodic checks with the default configurations.
|
|
31
|
-
*/
|
|
32
|
-
"enabledDefaultConfigs"
|
|
33
|
-
/**
|
|
34
|
-
* Disables the periodic checks.
|
|
35
|
-
*/
|
|
36
|
-
| "disabled"
|
|
37
|
-
/**
|
|
38
|
-
* Manually configured interval for periodic checks.
|
|
39
|
-
*/
|
|
40
|
-
| PeriodicChecksManualInterval;
|
|
41
|
-
export declare namespace GlideClusterClientConfiguration {
|
|
42
|
-
/**
|
|
43
|
-
* Enum representing pubsub subscription modes.
|
|
44
|
-
* @see {@link https://valkey.io/docs/topics/pubsub/|Valkey PubSub Documentation} for more details.
|
|
45
|
-
*/
|
|
46
|
-
enum PubSubChannelModes {
|
|
47
|
-
/**
|
|
48
|
-
* Use exact channel names.
|
|
49
|
-
*/
|
|
50
|
-
Exact = 0,
|
|
51
|
-
/**
|
|
52
|
-
* Use channel name patterns.
|
|
53
|
-
*/
|
|
54
|
-
Pattern = 1,
|
|
55
|
-
/**
|
|
56
|
-
* Use sharded pubsub. Available since Valkey version 7.0.
|
|
57
|
-
*/
|
|
58
|
-
Sharded = 2
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Configuration for Pub/Sub subscriptions that the client will establish upon connection.
|
|
62
|
-
*/
|
|
63
|
-
interface PubSubSubscriptions {
|
|
64
|
-
/**
|
|
65
|
-
* Channels and patterns by modes.
|
|
66
|
-
*/
|
|
67
|
-
channelsAndPatterns: Partial<Record<PubSubChannelModes, Set<string>>>;
|
|
68
|
-
/**
|
|
69
|
-
* Optional callback to accept the incoming messages.
|
|
70
|
-
*/
|
|
71
|
-
callback?: (msg: PubSubMsg, context: any) => void;
|
|
72
|
-
/**
|
|
73
|
-
* Arbitrary context to pass to the callback.
|
|
74
|
-
*/
|
|
75
|
-
context?: any;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Configuration options for creating a {@link GlideClusterClient | GlideClusterClient}.
|
|
80
|
-
*
|
|
81
|
-
* Extends {@link BaseClientConfiguration | BaseClientConfiguration} with properties specific to `GlideClusterClient`, such as periodic topology checks
|
|
82
|
-
* and Pub/Sub subscription settings.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This configuration allows you to tailor the client's behavior when connecting to a Valkey GLIDE Cluster.
|
|
86
|
-
*
|
|
87
|
-
* - **Periodic Topology Checks**: Use `periodicChecks` to configure how the client performs periodic checks to detect changes in the cluster's topology.
|
|
88
|
-
* - `"enabledDefaultConfigs"`: Enables periodic checks with default configurations.
|
|
89
|
-
* - `"disabled"`: Disables periodic topology checks.
|
|
90
|
-
* - `{ duration_in_sec: number }`: Manually configure the interval for periodic checks.
|
|
91
|
-
* - **Pub/Sub Subscriptions**: Predefine Pub/Sub channels and patterns to subscribe to upon connection establishment.
|
|
92
|
-
* - Supports exact channels, patterns, and sharded channels (available since Valkey version 7.0).
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const config: GlideClusterClientConfiguration = {
|
|
97
|
-
* periodicChecks: {
|
|
98
|
-
* duration_in_sec: 30, // Perform periodic checks every 30 seconds
|
|
99
|
-
* },
|
|
100
|
-
* pubsubSubscriptions: {
|
|
101
|
-
* channelsAndPatterns: {
|
|
102
|
-
* [GlideClusterClientConfiguration.PubSubChannelModes.Pattern]: new Set(['cluster.*']),
|
|
103
|
-
* },
|
|
104
|
-
* callback: (msg) => {
|
|
105
|
-
* console.log(`Received message on ${msg.channel}:`, msg.payload);
|
|
106
|
-
* },
|
|
107
|
-
* },
|
|
108
|
-
* };
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export type GlideClusterClientConfiguration = BaseClientConfiguration & {
|
|
112
|
-
/**
|
|
113
|
-
* Configure the periodic topology checks.
|
|
114
|
-
* These checks evaluate changes in the cluster's topology, triggering a slot refresh when detected.
|
|
115
|
-
* Periodic checks ensure a quick and efficient process by querying a limited number of nodes.
|
|
116
|
-
* If not set, `enabledDefaultConfigs` will be used.
|
|
117
|
-
*/
|
|
118
|
-
periodicChecks?: PeriodicChecks;
|
|
119
|
-
/**
|
|
120
|
-
* PubSub subscriptions to be used for the client.
|
|
121
|
-
* Will be applied via SUBSCRIBE/PSUBSCRIBE/SSUBSCRIBE commands during connection establishment.
|
|
122
|
-
*/
|
|
123
|
-
pubsubSubscriptions?: GlideClusterClientConfiguration.PubSubSubscriptions;
|
|
124
|
-
/**
|
|
125
|
-
* Advanced configuration settings for the client.
|
|
126
|
-
*/
|
|
127
|
-
advancedConfiguration?: AdvancedGlideClusterClientConfiguration;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Represents advanced configuration settings for creating a {@link GlideClusterClient | GlideClusterClient} used in {@link GlideClusterClientConfiguration | GlideClusterClientConfiguration}.
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const config: AdvancedGlideClusterClientConfiguration = {
|
|
136
|
-
* connectionTimeout: 500, // Set the connection timeout to 500ms
|
|
137
|
-
* };
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
export type AdvancedGlideClusterClientConfiguration = AdvancedBaseClientConfiguration & {};
|
|
141
|
-
/**
|
|
142
|
-
* If the command's routing is to one node we will get T as a response type,
|
|
143
|
-
* otherwise, we will get a dictionary of address: nodeResponse, address is of type string and nodeResponse is of type T.
|
|
144
|
-
*/
|
|
145
|
-
export type ClusterResponse<T> = T | Record<string, T>;
|
|
146
|
-
/**
|
|
147
|
-
* Routing configuration for commands based on a specific slot ID in a Valkey cluster.
|
|
148
|
-
*
|
|
149
|
-
* @remarks
|
|
150
|
-
* This interface allows you to specify routing of a command to a node responsible for a particular slot ID in the cluster.
|
|
151
|
-
* Valkey clusters use hash slots to distribute data across multiple shards. There are 16,384 slots in total, and each shard
|
|
152
|
-
* manages a range of slots.
|
|
153
|
-
*
|
|
154
|
-
* - **Slot ID**: A number between 0 and 16383 representing a hash slot.
|
|
155
|
-
* - **Routing Type**:
|
|
156
|
-
* - `"primarySlotId"`: Routes the command to the primary node responsible for the specified slot ID.
|
|
157
|
-
* - `"replicaSlotId"`: Routes the command to a replica node responsible for the specified slot ID, overriding the `readFrom` configuration.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* // Route command to the primary node responsible for slot ID 12345
|
|
162
|
-
* const routeBySlotId: SlotIdTypes = {
|
|
163
|
-
* type: "primarySlotId",
|
|
164
|
-
* id: 12345,
|
|
165
|
-
* };
|
|
166
|
-
*
|
|
167
|
-
* // Route command to a replica node responsible for slot ID 12345
|
|
168
|
-
* const routeToReplicaBySlotId: SlotIdTypes = {
|
|
169
|
-
* type: "replicaSlotId",
|
|
170
|
-
* id: 12345,
|
|
171
|
-
* };
|
|
172
|
-
*
|
|
173
|
-
* // Use the routing configuration when executing a command
|
|
174
|
-
* const result = await client.get("mykey", { route: routeBySlotId });
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
177
|
-
export interface SlotIdTypes {
|
|
178
|
-
/**
|
|
179
|
-
* `replicaSlotId` overrides the `readFrom` configuration. If it's used the request
|
|
180
|
-
* will be routed to a replica, even if the strategy is `alwaysFromPrimary`.
|
|
181
|
-
*/
|
|
182
|
-
type: "primarySlotId" | "replicaSlotId";
|
|
183
|
-
/**
|
|
184
|
-
* Slot number. There are 16384 slots in a Valkey cluster, and each shard manages a slot range.
|
|
185
|
-
* Unless the slot is known, it's better to route using `SlotKeyTypes`
|
|
186
|
-
*/
|
|
187
|
-
id: number;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Routing configuration for commands based on a key in a Valkey cluster.
|
|
191
|
-
*
|
|
192
|
-
* @remarks
|
|
193
|
-
* This interface allows you to specify routing of a command to a node responsible for the slot that a specific key hashes to.
|
|
194
|
-
* Valkey clusters use consistent hashing to map keys to hash slots, which are then managed by different shards in the cluster.
|
|
195
|
-
*
|
|
196
|
-
* - **Key**: The key whose hash slot will determine the routing of the command.
|
|
197
|
-
* - **Routing Type**:
|
|
198
|
-
* - `"primarySlotKey"`: Routes the command to the primary node responsible for the key's slot.
|
|
199
|
-
* - `"replicaSlotKey"`: Routes the command to a replica node responsible for the key's slot, overriding the `readFrom` configuration.
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```typescript
|
|
203
|
-
* // Route command to the primary node responsible for the key's slot
|
|
204
|
-
* const routeByKey: SlotKeyTypes = {
|
|
205
|
-
* type: "primarySlotKey",
|
|
206
|
-
* key: "user:1001",
|
|
207
|
-
* };
|
|
208
|
-
*
|
|
209
|
-
* // Route command to a replica node responsible for the key's slot
|
|
210
|
-
* const routeToReplicaByKey: SlotKeyTypes = {
|
|
211
|
-
* type: "replicaSlotKey",
|
|
212
|
-
* key: "user:1001",
|
|
213
|
-
* };
|
|
214
|
-
*
|
|
215
|
-
* // Use the routing configuration when executing a command
|
|
216
|
-
* const result = await client.get("user:1001", { route: routeByKey });
|
|
217
|
-
* ```
|
|
218
|
-
*/
|
|
219
|
-
export interface SlotKeyTypes {
|
|
220
|
-
/**
|
|
221
|
-
* `replicaSlotKey` overrides the `readFrom` configuration. If it's used the request
|
|
222
|
-
* will be routed to a replica, even if the strategy is `alwaysFromPrimary`.
|
|
223
|
-
*/
|
|
224
|
-
type: "primarySlotKey" | "replicaSlotKey";
|
|
225
|
-
/**
|
|
226
|
-
* The request will be sent to nodes managing this key.
|
|
227
|
-
*/
|
|
228
|
-
key: string;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Routing configuration to send a command to a specific node by its address and port.
|
|
232
|
-
*
|
|
233
|
-
* @remarks
|
|
234
|
-
* This interface allows you to specify routing of a command to a node in the Valkey cluster by providing its network address and port.
|
|
235
|
-
* It's useful when you need to direct a command to a particular node.
|
|
236
|
-
*
|
|
237
|
-
* - **Type**: Must be set to `"routeByAddress"` to indicate that the routing should be based on the provided address.
|
|
238
|
-
* - **Host**: The endpoint of the node.
|
|
239
|
-
* - If `port` is not provided, `host` should be in the format `${address}:${port}`, where `address` is the preferred endpoint as shown in the output of the `CLUSTER SLOTS` command.
|
|
240
|
-
* - If `port` is provided, `host` should be the address or hostname of the node without the port.
|
|
241
|
-
* - **Port**: (Optional) The port to access on the node.
|
|
242
|
-
* - If `port` is not provided, `host` is assumed to include the port number.
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```typescript
|
|
246
|
-
* // Route command to a node at '192.168.1.10:6379'
|
|
247
|
-
* const routeByAddress: RouteByAddress = {
|
|
248
|
-
* type: "routeByAddress",
|
|
249
|
-
* host: "192.168.1.10",
|
|
250
|
-
* port: 6379,
|
|
251
|
-
* };
|
|
252
|
-
*
|
|
253
|
-
* // Alternatively, include the port in the host string
|
|
254
|
-
* const routeByAddressWithPortInHost: RouteByAddress = {
|
|
255
|
-
* type: "routeByAddress",
|
|
256
|
-
* host: "192.168.1.10:6379",
|
|
257
|
-
* };
|
|
258
|
-
*
|
|
259
|
-
* // Use the routing configuration when executing a command
|
|
260
|
-
* const result = await client.ping({ route: routeByAddress });
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
export interface RouteByAddress {
|
|
264
|
-
type: "routeByAddress";
|
|
265
|
-
/**
|
|
266
|
-
*The endpoint of the node. If `port` is not provided, should be in the `${address}:${port}` format, where `address` is the preferred endpoint as shown in the output of the `CLUSTER SLOTS` command.
|
|
267
|
-
*/
|
|
268
|
-
host: string;
|
|
269
|
-
/**
|
|
270
|
-
* The port to access on the node. If port is not provided, `host` is assumed to be in the format `${address}:${port}`.
|
|
271
|
-
*/
|
|
272
|
-
port?: number;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Defines the routing configuration for a command in a Valkey cluster.
|
|
276
|
-
*
|
|
277
|
-
* @remarks
|
|
278
|
-
* The `Routes` type allows you to specify how a command should be routed in a Valkey cluster.
|
|
279
|
-
* Commands can be routed to a single node or broadcast to multiple nodes depending on the routing strategy.
|
|
280
|
-
*
|
|
281
|
-
* **Routing Options**:
|
|
282
|
-
*
|
|
283
|
-
* - **Single Node Routing** (`SingleNodeRoute`):
|
|
284
|
-
* - **"randomNode"**: Route the command to a random node in the cluster.
|
|
285
|
-
* - **`SlotIdTypes`**: Route based on a specific slot ID.
|
|
286
|
-
* - **`SlotKeyTypes`**: Route based on the slot of a specific key.
|
|
287
|
-
* - **`RouteByAddress`**: Route to a specific node by its address and port.
|
|
288
|
-
* - **Broadcast Routing**:
|
|
289
|
-
* - **"allPrimaries"**: Route the command to all primary nodes in the cluster.
|
|
290
|
-
* - **"allNodes"**: Route the command to all nodes (both primaries and replicas) in the cluster.
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* ```typescript
|
|
294
|
-
* // Route command to a random node
|
|
295
|
-
* const routeRandom: Routes = "randomNode";
|
|
296
|
-
*
|
|
297
|
-
* // Route command to all primary nodes
|
|
298
|
-
* const routeAllPrimaries: Routes = "allPrimaries";
|
|
299
|
-
*
|
|
300
|
-
* // Route command to all nodes
|
|
301
|
-
* const routeAllNodes: Routes = "allNodes";
|
|
302
|
-
*
|
|
303
|
-
* // Route command to a node by slot key
|
|
304
|
-
* const routeByKey: Routes = {
|
|
305
|
-
* type: "primarySlotKey",
|
|
306
|
-
* key: "myKey",
|
|
307
|
-
* };
|
|
308
|
-
*
|
|
309
|
-
* // Route command to a specific node by address
|
|
310
|
-
* const routeByAddress: Routes = {
|
|
311
|
-
* type: "routeByAddress",
|
|
312
|
-
* host: "192.168.1.10",
|
|
313
|
-
* port: 6379,
|
|
314
|
-
* };
|
|
315
|
-
*
|
|
316
|
-
* // Use the routing configuration when executing a command
|
|
317
|
-
* const result = await client.ping({ route: routeByAddress });
|
|
318
|
-
* ```
|
|
319
|
-
*/
|
|
320
|
-
export type Routes = SingleNodeRoute
|
|
321
|
-
/**
|
|
322
|
-
* Route request to all primary nodes.
|
|
323
|
-
*/
|
|
324
|
-
| "allPrimaries"
|
|
325
|
-
/**
|
|
326
|
-
* Route request to all nodes.
|
|
327
|
-
*/
|
|
328
|
-
| "allNodes";
|
|
329
|
-
/**
|
|
330
|
-
* Defines the routing configuration to a single node in the Valkey cluster.
|
|
331
|
-
*
|
|
332
|
-
* @remarks
|
|
333
|
-
* The `SingleNodeRoute` type allows you to specify routing of a command to a single node in the cluster.
|
|
334
|
-
* This can be based on various criteria such as a random node, a node responsible for a specific slot, or a node identified by its address.
|
|
335
|
-
*
|
|
336
|
-
* **Options**:
|
|
337
|
-
*
|
|
338
|
-
* - **"randomNode"**: Route the command to a random node in the cluster.
|
|
339
|
-
* - **`SlotIdTypes`**: Route to the node responsible for a specific slot ID.
|
|
340
|
-
* - **`SlotKeyTypes`**: Route to the node responsible for the slot of a specific key.
|
|
341
|
-
* - **`RouteByAddress`**: Route to a specific node by its address and port.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
* ```typescript
|
|
345
|
-
* // Route to a random node
|
|
346
|
-
* const routeRandomNode: SingleNodeRoute = "randomNode";
|
|
347
|
-
*
|
|
348
|
-
* // Route based on slot ID
|
|
349
|
-
* const routeBySlotId: SingleNodeRoute = {
|
|
350
|
-
* type: "primarySlotId",
|
|
351
|
-
* id: 12345,
|
|
352
|
-
* };
|
|
353
|
-
*
|
|
354
|
-
* // Route based on key
|
|
355
|
-
* const routeByKey: SingleNodeRoute = {
|
|
356
|
-
* type: "primarySlotKey",
|
|
357
|
-
* key: "myKey",
|
|
358
|
-
* };
|
|
359
|
-
*
|
|
360
|
-
* // Route to a specific node by address
|
|
361
|
-
* const routeByAddress: SingleNodeRoute = {
|
|
362
|
-
* type: "routeByAddress",
|
|
363
|
-
* host: "192.168.1.10",
|
|
364
|
-
* port: 6379,
|
|
365
|
-
* };
|
|
366
|
-
*
|
|
367
|
-
* // Use the routing configuration when executing a command
|
|
368
|
-
* const result = await client.get("myKey", { route: routeByKey });
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
export type SingleNodeRoute =
|
|
372
|
-
/**
|
|
373
|
-
* Route request to a random node.
|
|
374
|
-
*/
|
|
375
|
-
"randomNode"
|
|
376
|
-
/**
|
|
377
|
-
* Route request to the node that contains the slot with the given id.
|
|
378
|
-
*/
|
|
379
|
-
| SlotIdTypes
|
|
380
|
-
/**
|
|
381
|
-
* Route request to the node that contains the slot that the given key matches.
|
|
382
|
-
*/
|
|
383
|
-
| SlotKeyTypes | RouteByAddress;
|
|
384
|
-
/**
|
|
385
|
-
* Client used for connection to cluster servers.
|
|
386
|
-
*
|
|
387
|
-
* @see For full documentation refer to {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#cluster|Valkey Glide Wiki}.
|
|
388
|
-
*/
|
|
389
|
-
export declare class GlideClusterClient extends BaseClient {
|
|
390
|
-
/**
|
|
391
|
-
* Creates a new `GlideClusterClient` instance and establishes connections to a Valkey GLIDE Cluster.
|
|
392
|
-
*
|
|
393
|
-
* @param options - The configuration options for the client, including cluster addresses, authentication credentials, TLS settings, periodic checks, and Pub/Sub subscriptions.
|
|
394
|
-
* @returns A promise that resolves to a connected `GlideClusterClient` instance.
|
|
395
|
-
*
|
|
396
|
-
* @remarks
|
|
397
|
-
* Use this static method to create and connect a `GlideClusterClient` to a Valkey GLIDE Cluster. The client will automatically handle connection establishment, including cluster topology discovery and handling of authentication and TLS configurations.
|
|
398
|
-
*
|
|
399
|
-
* ### Example - Connecting to a Cluster
|
|
400
|
-
* ```typescript
|
|
401
|
-
* import { GlideClusterClient, GlideClusterClientConfiguration } from '@valkey/valkey-glide';
|
|
402
|
-
*
|
|
403
|
-
* const client = await GlideClusterClient.createClient({
|
|
404
|
-
* addresses: [
|
|
405
|
-
* { host: 'address1.example.com', port: 6379 },
|
|
406
|
-
* { host: 'address2.example.com', port: 6379 },
|
|
407
|
-
* ],
|
|
408
|
-
* credentials: {
|
|
409
|
-
* username: 'user1',
|
|
410
|
-
* password: 'passwordA',
|
|
411
|
-
* },
|
|
412
|
-
* useTLS: true,
|
|
413
|
-
* periodicChecks: {
|
|
414
|
-
* duration_in_sec: 30, // Perform periodic checks every 30 seconds
|
|
415
|
-
* },
|
|
416
|
-
* pubsubSubscriptions: {
|
|
417
|
-
* channelsAndPatterns: {
|
|
418
|
-
* [GlideClusterClientConfiguration.PubSubChannelModes.Exact]: new Set(['updates']),
|
|
419
|
-
* [GlideClusterClientConfiguration.PubSubChannelModes.Sharded]: new Set(['sharded_channel']),
|
|
420
|
-
* },
|
|
421
|
-
* callback: (msg) => {
|
|
422
|
-
* console.log(`Received message: ${msg.payload}`);
|
|
423
|
-
* },
|
|
424
|
-
* },
|
|
425
|
-
* });
|
|
426
|
-
* ```
|
|
427
|
-
*
|
|
428
|
-
* @remarks
|
|
429
|
-
* - **Cluster Topology Discovery**: The client will automatically discover the cluster topology based on the seed addresses provided.
|
|
430
|
-
* - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
|
|
431
|
-
* - **TLS**: If `useTLS` is set to `true`, the client will establish secure connections using TLS.
|
|
432
|
-
* - **Periodic Checks**: The `periodicChecks` setting allows you to configure how often the client checks for cluster topology changes.
|
|
433
|
-
* - **Pub/Sub Subscriptions**: Any channels or patterns specified in `pubsubSubscriptions` will be subscribed to upon connection.
|
|
434
|
-
*/
|
|
435
|
-
static createClient(options: GlideClusterClientConfiguration): Promise<GlideClusterClient>;
|
|
436
|
-
/**
|
|
437
|
-
* Incrementally iterates over the keys in the Cluster.
|
|
438
|
-
*
|
|
439
|
-
* This command is similar to the `SCAN` command but designed for Cluster environments.
|
|
440
|
-
* It uses a {@link ClusterScanCursor} object to manage iterations.
|
|
441
|
-
*
|
|
442
|
-
* For each iteration, use the new cursor object to continue the scan.
|
|
443
|
-
* Using the same cursor object for multiple iterations may result in unexpected behavior.
|
|
444
|
-
*
|
|
445
|
-
* For more information about the Cluster Scan implementation, see
|
|
446
|
-
* {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#cluster-scan | Cluster Scan}.
|
|
447
|
-
*
|
|
448
|
-
* This method can iterate over all keys in the database from the start of the scan until it ends.
|
|
449
|
-
* The same key may be returned in multiple scan iterations.
|
|
450
|
-
* The API does not accept `route` as it go through all slots in the cluster.
|
|
451
|
-
*
|
|
452
|
-
* @see {@link https://valkey.io/commands/scan/ | valkey.io} for more details.
|
|
453
|
-
*
|
|
454
|
-
* @param cursor - The cursor object that wraps the scan state.
|
|
455
|
-
* To start a new scan, create a new empty `ClusterScanCursor` using {@link ClusterScanCursor}.
|
|
456
|
-
* @param options - (Optional) The scan options, see {@link ClusterScanOptions} and {@link DecoderOption}.
|
|
457
|
-
* @returns A Promise resolving to an array containing the next cursor and an array of keys,
|
|
458
|
-
* formatted as [`ClusterScanCursor`, `string[]`].
|
|
459
|
-
*
|
|
460
|
-
* @example
|
|
461
|
-
* ```typescript
|
|
462
|
-
* // Iterate over all keys in the cluster
|
|
463
|
-
* await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "key3", value: "value3"}]);
|
|
464
|
-
* let cursor = new ClusterScanCursor();
|
|
465
|
-
* const allKeys: GlideString[] = [];
|
|
466
|
-
* let keys: GlideString[] = [];
|
|
467
|
-
* while (!cursor.isFinished()) {
|
|
468
|
-
* [cursor, keys] = await client.scan(cursor, { count: 10 });
|
|
469
|
-
* allKeys.push(...keys);
|
|
470
|
-
* }
|
|
471
|
-
* console.log(allKeys); // ["key1", "key2", "key3"]
|
|
472
|
-
*
|
|
473
|
-
* // Iterate over keys matching a pattern
|
|
474
|
-
* await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "notMyKey", value: "value3"}, {key: "somethingElse", value: "value4"}]);
|
|
475
|
-
* let cursor = new ClusterScanCursor();
|
|
476
|
-
* const matchedKeys: GlideString[] = [];
|
|
477
|
-
* while (!cursor.isFinished()) {
|
|
478
|
-
* const [cursor, keys] = await client.scan(cursor, { match: "*key*", count: 10 });
|
|
479
|
-
* matchedKeys.push(...keys);
|
|
480
|
-
* }
|
|
481
|
-
* console.log(matchedKeys); // ["key1", "key2", "notMyKey"]
|
|
482
|
-
*
|
|
483
|
-
* // Iterate over keys of a specific type
|
|
484
|
-
* await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "key3", value: "value3"}]);
|
|
485
|
-
* await client.sadd("thisIsASet", ["value4"]);
|
|
486
|
-
* let cursor = new ClusterScanCursor();
|
|
487
|
-
* const stringKeys: GlideString[] = [];
|
|
488
|
-
* while (!cursor.isFinished()) {
|
|
489
|
-
* const [cursor, keys] = await client.scan(cursor, { type: object.STRING });
|
|
490
|
-
* stringKeys.push(...keys);
|
|
491
|
-
* }
|
|
492
|
-
* console.log(stringKeys); // ["key1", "key2", "key3"]
|
|
493
|
-
* ```
|
|
494
|
-
*/
|
|
495
|
-
scan(cursor: ClusterScanCursor, options?: ClusterScanOptions & DecoderOption): Promise<[ClusterScanCursor, GlideString[]]>;
|
|
496
|
-
/** Executes a single command, without checking inputs. Every part of the command, including subcommands,
|
|
497
|
-
* should be added as a separate value in args.
|
|
498
|
-
* The command will be routed automatically based on the passed command's default request policy, unless `route` is provided,
|
|
499
|
-
* in which case the client will route the command to the nodes defined by `route`.
|
|
500
|
-
*
|
|
501
|
-
* Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
|
|
502
|
-
*
|
|
503
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command|Glide for Valkey Wiki} for details on the restrictions and limitations of the custom command API.
|
|
504
|
-
*
|
|
505
|
-
* @param args - A list including the command name and arguments for the custom command.
|
|
506
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}
|
|
507
|
-
* @returns The executed custom command return value.
|
|
508
|
-
*
|
|
509
|
-
* @example
|
|
510
|
-
* ```typescript
|
|
511
|
-
* // Example usage of customCommand method to retrieve pub/sub clients with routing to all primary nodes
|
|
512
|
-
* const result = await client.customCommand(["CLIENT", "LIST", "TYPE", "PUBSUB"], {route: "allPrimaries", decoder: Decoder.String});
|
|
513
|
-
* console.log(result); // Output: Returns a list of all pub/sub clients
|
|
514
|
-
* ```
|
|
515
|
-
*/
|
|
516
|
-
customCommand(args: GlideString[], options?: RouteOption & DecoderOption): Promise<ClusterResponse<GlideReturnType>>;
|
|
517
|
-
/**
|
|
518
|
-
* Execute a transaction by processing the queued commands.
|
|
519
|
-
*
|
|
520
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey Glide Wiki} for details on Valkey Transactions.
|
|
521
|
-
*
|
|
522
|
-
* @param transaction - A {@link ClusterTransaction} object containing a list of commands to be executed.
|
|
523
|
-
*
|
|
524
|
-
* @param options - (Optional) Additional parameters:
|
|
525
|
-
* - (Optional) `route`: If `route` is not provided, the transaction will be routed to the slot owner of the first key found in the transaction.
|
|
526
|
-
* If no key is found, the command will be sent to a random node.
|
|
527
|
-
* If `route` is provided, the client will route the command to the nodes defined by `route`.
|
|
528
|
-
* - (Optional) `decoder`: See {@link DecoderOption}.
|
|
529
|
-
* @returns A list of results corresponding to the execution of each command in the transaction.
|
|
530
|
-
* If a command returns a value, it will be included in the list. If a command doesn't return a value,
|
|
531
|
-
* the list entry will be `null`.
|
|
532
|
-
* If the transaction failed due to a `WATCH` command, `exec` will return `null`.
|
|
533
|
-
*/
|
|
534
|
-
exec(transaction: ClusterTransaction, options?: {
|
|
535
|
-
route?: SingleNodeRoute;
|
|
536
|
-
} & DecoderOption): Promise<GlideReturnType[] | null>;
|
|
537
|
-
/**
|
|
538
|
-
* Pings the server.
|
|
539
|
-
*
|
|
540
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
541
|
-
*
|
|
542
|
-
* @see {@link https://valkey.io/commands/ping/|valkey.io} for details.
|
|
543
|
-
*
|
|
544
|
-
* @param options - (Optional) Additional parameters:
|
|
545
|
-
* - (Optional) `message` : a message to include in the `PING` command.
|
|
546
|
-
* + If not provided, the server will respond with `"PONG"`.
|
|
547
|
-
* + If provided, the server will respond with a copy of the message.
|
|
548
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
549
|
-
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
550
|
-
* @returns `"PONG"` if `message` is not provided, otherwise return a copy of `message`.
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* ```typescript
|
|
554
|
-
* // Example usage of ping method without any message
|
|
555
|
-
* const result = await client.ping();
|
|
556
|
-
* console.log(result); // Output: 'PONG'
|
|
557
|
-
* ```
|
|
558
|
-
*
|
|
559
|
-
* @example
|
|
560
|
-
* ```typescript
|
|
561
|
-
* // Example usage of ping method with a message
|
|
562
|
-
* const result = await client.ping("Hello");
|
|
563
|
-
* console.log(result); // Output: 'Hello'
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
ping(options?: {
|
|
567
|
-
message?: GlideString;
|
|
568
|
-
} & RouteOption & DecoderOption): Promise<GlideString>;
|
|
569
|
-
/**
|
|
570
|
-
* Gets information and statistics about the server.
|
|
571
|
-
*
|
|
572
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
573
|
-
*
|
|
574
|
-
* @see {@link https://valkey.io/commands/info/|valkey.io} for details.
|
|
575
|
-
*
|
|
576
|
-
* @param options - (Optional) Additional parameters:
|
|
577
|
-
* - (Optional) `sections`: a list of {@link InfoOptions} values specifying which sections of information to retrieve.
|
|
578
|
-
* When no parameter is provided, {@link InfoOptions.Default|Default} is assumed.
|
|
579
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
580
|
-
* @returns A string containing the information for the sections requested.
|
|
581
|
-
* When specifying a route other than a single node,
|
|
582
|
-
* it returns a dictionary where each address is the key and its corresponding node response is the value.
|
|
583
|
-
*/
|
|
584
|
-
info(options?: {
|
|
585
|
-
sections?: InfoOptions[];
|
|
586
|
-
} & RouteOption): Promise<ClusterResponse<string>>;
|
|
587
|
-
/**
|
|
588
|
-
* Gets the name of the connection to which the request is routed.
|
|
589
|
-
*
|
|
590
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
591
|
-
*
|
|
592
|
-
* @see {@link https://valkey.io/commands/client-getname/|valkey.io} for details.
|
|
593
|
-
*
|
|
594
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
595
|
-
*
|
|
596
|
-
* @returns - The name of the client connection as a string if a name is set, or `null` if no name is assigned.
|
|
597
|
-
* When specifying a route other than a single node, it returns a dictionary where each address is the key and
|
|
598
|
-
* its corresponding node response is the value.
|
|
599
|
-
*
|
|
600
|
-
* @example
|
|
601
|
-
* ```typescript
|
|
602
|
-
* // Example usage of client_getname method
|
|
603
|
-
* const result = await client.client_getname();
|
|
604
|
-
* console.log(result); // Output: 'Connection Name'
|
|
605
|
-
* ```
|
|
606
|
-
*
|
|
607
|
-
* @example
|
|
608
|
-
* ```typescript
|
|
609
|
-
* // Example usage of clientGetName method with routing to all nodes
|
|
610
|
-
* const result = await client.clientGetName('allNodes');
|
|
611
|
-
* console.log(result); // Output: {'addr': 'Connection Name', 'addr2': 'Connection Name', 'addr3': 'Connection Name'}
|
|
612
|
-
* ```
|
|
613
|
-
*/
|
|
614
|
-
clientGetName(options?: RouteOption & DecoderOption): Promise<ClusterResponse<GlideString | null>>;
|
|
615
|
-
/**
|
|
616
|
-
* Rewrites the configuration file with the current configuration.
|
|
617
|
-
*
|
|
618
|
-
* The command will be routed to a all nodes, unless `route` is provided.
|
|
619
|
-
*
|
|
620
|
-
* @see {@link https://valkey.io/commands/config-rewrite/|valkey.io} for details.
|
|
621
|
-
*
|
|
622
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
623
|
-
* @returns `"OK"` when the configuration was rewritten properly. Otherwise, an error is thrown.
|
|
624
|
-
*
|
|
625
|
-
* @example
|
|
626
|
-
* ```typescript
|
|
627
|
-
* // Example usage of configRewrite command
|
|
628
|
-
* const result = await client.configRewrite();
|
|
629
|
-
* console.log(result); // Output: 'OK'
|
|
630
|
-
* ```
|
|
631
|
-
*/
|
|
632
|
-
configRewrite(options?: RouteOption): Promise<"OK">;
|
|
633
|
-
/**
|
|
634
|
-
* Resets the statistics reported by the server using the `INFO` and `LATENCY HISTOGRAM` commands.
|
|
635
|
-
*
|
|
636
|
-
* The command will be routed to all nodes, unless `route` is provided.
|
|
637
|
-
*
|
|
638
|
-
* @see {@link https://valkey.io/commands/config-resetstat/|valkey.io} for details.
|
|
639
|
-
*
|
|
640
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
641
|
-
* @returns always `"OK"`.
|
|
642
|
-
*
|
|
643
|
-
* @example
|
|
644
|
-
* ```typescript
|
|
645
|
-
* // Example usage of configResetStat command
|
|
646
|
-
* const result = await client.configResetStat();
|
|
647
|
-
* console.log(result); // Output: 'OK'
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
configResetStat(options?: RouteOption): Promise<"OK">;
|
|
651
|
-
/**
|
|
652
|
-
* Returns the current connection ID.
|
|
653
|
-
*
|
|
654
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
655
|
-
*
|
|
656
|
-
* @see {@link https://valkey.io/commands/client-id/|valkey.io} for details.
|
|
657
|
-
*
|
|
658
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
659
|
-
* @returns The ID of the connection. When specifying a route other than a single node,
|
|
660
|
-
* it returns a dictionary where each address is the key and its corresponding node response is the value.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* ```typescript
|
|
664
|
-
* const result = await client.clientId();
|
|
665
|
-
* console.log("Connection id: " + result);
|
|
666
|
-
* ```
|
|
667
|
-
*/
|
|
668
|
-
clientId(options?: RouteOption): Promise<ClusterResponse<number>>;
|
|
669
|
-
/**
|
|
670
|
-
* Reads the configuration parameters of the running server.
|
|
671
|
-
* Starting from server version 7, command supports multiple parameters.
|
|
672
|
-
*
|
|
673
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
674
|
-
*
|
|
675
|
-
* @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
|
|
676
|
-
*
|
|
677
|
-
* @param parameters - A list of configuration parameter names to retrieve values for.
|
|
678
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
679
|
-
*
|
|
680
|
-
* @returns A map of values corresponding to the configuration parameters. When specifying a route other than a single node,
|
|
681
|
-
* it returns a dictionary where each address is the key and its corresponding node response is the value.
|
|
682
|
-
*
|
|
683
|
-
* @example
|
|
684
|
-
* ```typescript
|
|
685
|
-
* // Example usage of config_get method with a single configuration parameter with routing to a random node
|
|
686
|
-
* const result = await client.config_get(["timeout"], "randomNode");
|
|
687
|
-
* console.log(result); // Output: {'timeout': '1000'}
|
|
688
|
-
* ```
|
|
689
|
-
*
|
|
690
|
-
* @example
|
|
691
|
-
* ```typescript
|
|
692
|
-
* // Example usage of configGet method with multiple configuration parameters
|
|
693
|
-
* const result = await client.configGet(["timeout", "maxmemory"]);
|
|
694
|
-
* console.log(result); // Output: {'timeout': '1000', 'maxmemory': '1GB'}
|
|
695
|
-
* ```
|
|
696
|
-
*/
|
|
697
|
-
configGet(parameters: string[], options?: RouteOption & DecoderOption): Promise<ClusterResponse<Record<string, GlideString>>>;
|
|
698
|
-
/**
|
|
699
|
-
* Sets configuration parameters to the specified values.
|
|
700
|
-
* Starting from server version 7, command supports multiple parameters.
|
|
701
|
-
*
|
|
702
|
-
* The command will be routed to all nodes, unless `route` is provided.
|
|
703
|
-
*
|
|
704
|
-
* @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
|
|
705
|
-
*
|
|
706
|
-
* @param parameters - A map consisting of configuration parameters and their respective values to set.
|
|
707
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
708
|
-
* @returns "OK" when the configuration was set properly. Otherwise an error is thrown.
|
|
709
|
-
*
|
|
710
|
-
* @example
|
|
711
|
-
* ```typescript
|
|
712
|
-
* // Example usage of configSet method to set multiple configuration parameters
|
|
713
|
-
* const result = await client.configSet({ timeout: "1000", maxmemory: "1GB" });
|
|
714
|
-
* console.log(result); // Output: 'OK'
|
|
715
|
-
* ```
|
|
716
|
-
*/
|
|
717
|
-
configSet(parameters: Record<string, GlideString>, options?: RouteOption): Promise<"OK">;
|
|
718
|
-
/**
|
|
719
|
-
* Echoes the provided `message` back.
|
|
720
|
-
*
|
|
721
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
722
|
-
*
|
|
723
|
-
* @see {@link https://valkey.io/commands/echo/|valkey.io} for details.
|
|
724
|
-
*
|
|
725
|
-
* @param message - The message to be echoed back.
|
|
726
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
727
|
-
* @returns The provided `message`. When specifying a route other than a single node,
|
|
728
|
-
* it returns a dictionary where each address is the key and its corresponding node response is the value.
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```typescript
|
|
732
|
-
* // Example usage of the echo command
|
|
733
|
-
* const echoedMessage = await client.echo("valkey-glide");
|
|
734
|
-
* console.log(echoedMessage); // Output: "valkey-glide"
|
|
735
|
-
* ```
|
|
736
|
-
* @example
|
|
737
|
-
* ```typescript
|
|
738
|
-
* // Example usage of the echo command with routing to all nodes
|
|
739
|
-
* const echoedMessage = await client.echo("valkey-glide", "allNodes");
|
|
740
|
-
* console.log(echoedMessage); // Output: {'addr': 'valkey-glide', 'addr2': 'valkey-glide', 'addr3': 'valkey-glide'}
|
|
741
|
-
* ```
|
|
742
|
-
*/
|
|
743
|
-
echo(message: GlideString, options?: RouteOption & DecoderOption): Promise<ClusterResponse<GlideString>>;
|
|
744
|
-
/**
|
|
745
|
-
* Returns the server time.
|
|
746
|
-
*
|
|
747
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
748
|
-
*
|
|
749
|
-
* @see {@link https://valkey.io/commands/time/|valkey.io} for details.
|
|
750
|
-
*
|
|
751
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
752
|
-
*
|
|
753
|
-
* @returns The current server time as an `array` with two items:
|
|
754
|
-
* - A Unix timestamp,
|
|
755
|
-
* - The amount of microseconds already elapsed in the current second.
|
|
756
|
-
*
|
|
757
|
-
* When specifying a route other than a single node, it returns a dictionary where each address is the key and
|
|
758
|
-
* its corresponding node response is the value.
|
|
759
|
-
*
|
|
760
|
-
* @example
|
|
761
|
-
* ```typescript
|
|
762
|
-
* // Example usage of time method without any argument
|
|
763
|
-
* const result = await client.time();
|
|
764
|
-
* console.log(result); // Output: ['1710925775', '913580']
|
|
765
|
-
* ```
|
|
766
|
-
*
|
|
767
|
-
* @example
|
|
768
|
-
* ```typescript
|
|
769
|
-
* // Example usage of time method with routing to all nodes
|
|
770
|
-
* const result = await client.time('allNodes');
|
|
771
|
-
* console.log(result); // Output: {'addr': ['1710925775', '913580'], 'addr2': ['1710925775', '913580'], 'addr3': ['1710925775', '913580']}
|
|
772
|
-
* ```
|
|
773
|
-
*/
|
|
774
|
-
time(options?: RouteOption): Promise<ClusterResponse<[string, string]>>;
|
|
775
|
-
/**
|
|
776
|
-
* Copies the value stored at the `source` to the `destination` key. When `replace` is `true`,
|
|
777
|
-
* removes the `destination` key first if it already exists, otherwise performs no action.
|
|
778
|
-
*
|
|
779
|
-
* @see {@link https://valkey.io/commands/copy/|valkey.io} for details.
|
|
780
|
-
* @remarks When in cluster mode, `source` and `destination` must map to the same hash slot.
|
|
781
|
-
* @remarks Since Valkey version 6.2.0.
|
|
782
|
-
*
|
|
783
|
-
* @param source - The key to the source value.
|
|
784
|
-
* @param destination - The key where the value should be copied to.
|
|
785
|
-
* @param options - (Optional) Additional parameters:
|
|
786
|
-
* - (Optional) `replace`: if `true`, the `destination` key should be removed before copying the
|
|
787
|
-
* value to it. If not provided, no action will be performed if the key already exists.
|
|
788
|
-
* @returns `true` if `source` was copied, `false` if the `source` was not copied.
|
|
789
|
-
*
|
|
790
|
-
* @example
|
|
791
|
-
* ```typescript
|
|
792
|
-
* const result = await client.copy("set1", "set2", { replace: true });
|
|
793
|
-
* console.log(result); // Output: true - "set1" was copied to "set2".
|
|
794
|
-
* ```
|
|
795
|
-
*/
|
|
796
|
-
copy(source: GlideString, destination: GlideString, options?: {
|
|
797
|
-
replace?: boolean;
|
|
798
|
-
}): Promise<boolean>;
|
|
799
|
-
/**
|
|
800
|
-
* Displays a piece of generative computer art and the server version.
|
|
801
|
-
*
|
|
802
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
803
|
-
*
|
|
804
|
-
* @see {@link https://valkey.io/commands/lolwut/|valkey.io} for details.
|
|
805
|
-
*
|
|
806
|
-
* @param options - (Optional) The LOLWUT options - see {@link LolwutOptions} and {@link RouteOption}.
|
|
807
|
-
* @returns A piece of generative computer art along with the current server version.
|
|
808
|
-
*
|
|
809
|
-
* @example
|
|
810
|
-
* ```typescript
|
|
811
|
-
* const response = await client.lolwut({ version: 6, parameters: [40, 20] }, "allNodes");
|
|
812
|
-
* console.log(response); // Output: "Valkey ver. 7.2.3" - Indicates the current server version.
|
|
813
|
-
* ```
|
|
814
|
-
*/
|
|
815
|
-
lolwut(options?: LolwutOptions & RouteOption): Promise<ClusterResponse<string>>;
|
|
816
|
-
/**
|
|
817
|
-
* Invokes a previously loaded function.
|
|
818
|
-
*
|
|
819
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
820
|
-
*
|
|
821
|
-
* @see {@link https://valkey.io/commands/fcall/|valkey.io} for details.
|
|
822
|
-
* @remarks Since Valkey version 7.0.0.
|
|
823
|
-
*
|
|
824
|
-
* @param func - The function name.
|
|
825
|
-
* @param args - A list of `function` arguments and it should not represent names of keys.
|
|
826
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
827
|
-
* @returns The invoked function's return value.
|
|
828
|
-
*
|
|
829
|
-
* @example
|
|
830
|
-
* ```typescript
|
|
831
|
-
* const response = await client.fcallWithRoute("Deep_Thought", [], "randomNode");
|
|
832
|
-
* console.log(response); // Output: Returns the function's return value.
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
835
|
-
fcallWithRoute(func: GlideString, args: GlideString[], options?: RouteOption & DecoderOption): Promise<ClusterResponse<GlideReturnType>>;
|
|
836
|
-
/**
|
|
837
|
-
* Invokes a previously loaded read-only function.
|
|
838
|
-
*
|
|
839
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
840
|
-
*
|
|
841
|
-
* @see {@link https://valkey.io/commands/fcall/|valkey.io} for details.
|
|
842
|
-
* @remarks Since Valkey version 7.0.0.
|
|
843
|
-
*
|
|
844
|
-
* @param func - The function name.
|
|
845
|
-
* @param args - A list of `function` arguments and it should not represent names of keys.
|
|
846
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
847
|
-
* @returns The invoked function's return value.
|
|
848
|
-
*
|
|
849
|
-
* @example
|
|
850
|
-
* ```typescript
|
|
851
|
-
* const response = await client.fcallReadonlyWithRoute("Deep_Thought", ["Answer", "to", "the", "Ultimate",
|
|
852
|
-
* "Question", "of", "Life,", "the", "Universe,", "and", "Everything"], "randomNode");
|
|
853
|
-
* console.log(response); // Output: 42 # The return value on the function that was execute.
|
|
854
|
-
* ```
|
|
855
|
-
*/
|
|
856
|
-
fcallReadonlyWithRoute(func: GlideString, args: GlideString[], options?: RouteOption & DecoderOption): Promise<ClusterResponse<GlideReturnType>>;
|
|
857
|
-
/**
|
|
858
|
-
* Deletes a library and all its functions.
|
|
859
|
-
*
|
|
860
|
-
* @see {@link https://valkey.io/commands/function-delete/|valkey.io} for details.
|
|
861
|
-
* @remarks Since Valkey version 7.0.0.
|
|
862
|
-
*
|
|
863
|
-
* @param libraryCode - The library name to delete.
|
|
864
|
-
* @param route - (Optional) The command will be routed to all primary node, unless `route` is provided, in which
|
|
865
|
-
* case the client will route the command to the nodes defined by `route`.
|
|
866
|
-
* @returns A simple `"OK"` response.
|
|
867
|
-
*
|
|
868
|
-
* @example
|
|
869
|
-
* ```typescript
|
|
870
|
-
* const result = await client.functionDelete("libName");
|
|
871
|
-
* console.log(result); // Output: 'OK'
|
|
872
|
-
* ```
|
|
873
|
-
*/
|
|
874
|
-
functionDelete(libraryCode: GlideString, options?: RouteOption): Promise<"OK">;
|
|
875
|
-
/**
|
|
876
|
-
* Loads a library to Valkey.
|
|
877
|
-
*
|
|
878
|
-
* @see {@link https://valkey.io/commands/function-load/|valkey.io} for details.
|
|
879
|
-
* @remarks Since Valkey version 7.0.0.
|
|
880
|
-
*
|
|
881
|
-
* @param libraryCode - The source code that implements the library.
|
|
882
|
-
* @param options - (Optional) Additional parameters:
|
|
883
|
-
* - (Optional) `replace`: whether the given library should overwrite a library with the same name if it
|
|
884
|
-
* already exists.
|
|
885
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
886
|
-
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
887
|
-
* @returns The library name that was loaded.
|
|
888
|
-
*
|
|
889
|
-
* @example
|
|
890
|
-
* ```typescript
|
|
891
|
-
* const code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)";
|
|
892
|
-
* const result = await client.functionLoad(code, { replace: true, route: 'allNodes' });
|
|
893
|
-
* console.log(result); // Output: 'mylib'
|
|
894
|
-
* ```
|
|
895
|
-
*/
|
|
896
|
-
functionLoad(libraryCode: GlideString, options?: {
|
|
897
|
-
replace?: boolean;
|
|
898
|
-
} & RouteOption & DecoderOption): Promise<GlideString>;
|
|
899
|
-
/**
|
|
900
|
-
* Deletes all function libraries.
|
|
901
|
-
*
|
|
902
|
-
* @see {@link https://valkey.io/commands/function-flush/|valkey.io} for details.
|
|
903
|
-
* @remarks Since Valkey version 7.0.0.
|
|
904
|
-
*
|
|
905
|
-
* @param options - (Optional) Additional parameters:
|
|
906
|
-
* - (Optional) `mode`: the flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
|
|
907
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
908
|
-
* @returns A simple `"OK"` response.
|
|
909
|
-
*
|
|
910
|
-
* @example
|
|
911
|
-
* ```typescript
|
|
912
|
-
* const result = await client.functionFlush(FlushMode.SYNC);
|
|
913
|
-
* console.log(result); // Output: 'OK'
|
|
914
|
-
* ```
|
|
915
|
-
*/
|
|
916
|
-
functionFlush(options?: {
|
|
917
|
-
mode?: FlushMode;
|
|
918
|
-
} & RouteOption): Promise<"OK">;
|
|
919
|
-
/**
|
|
920
|
-
* Returns information about the functions and libraries.
|
|
921
|
-
*
|
|
922
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
923
|
-
*
|
|
924
|
-
* @see {@link https://valkey.io/commands/function-list/|valkey.io} for details.
|
|
925
|
-
* @remarks Since Valkey version 7.0.0.
|
|
926
|
-
*
|
|
927
|
-
* @param options - (Optional) See {@link FunctionListOptions}, {@link DecoderOption}, and {@link RouteOption}.
|
|
928
|
-
* @returns Info about all or selected libraries and their functions in {@link FunctionListResponse} format.
|
|
929
|
-
*
|
|
930
|
-
* @example
|
|
931
|
-
* ```typescript
|
|
932
|
-
* // Request info for specific library including the source code
|
|
933
|
-
* const result1 = await client.functionList({ libNamePattern: "myLib*", withCode: true });
|
|
934
|
-
* // Request info for all libraries
|
|
935
|
-
* const result2 = await client.functionList();
|
|
936
|
-
* console.log(result2); // Output:
|
|
937
|
-
* // [{
|
|
938
|
-
* // "library_name": "myLib5_backup",
|
|
939
|
-
* // "engine": "LUA",
|
|
940
|
-
* // "functions": [{
|
|
941
|
-
* // "name": "myfunc",
|
|
942
|
-
* // "description": null,
|
|
943
|
-
* // "flags": [ "no-writes" ],
|
|
944
|
-
* // }],
|
|
945
|
-
* // "library_code": "#!lua name=myLib5_backup \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
|
|
946
|
-
* // }]
|
|
947
|
-
* ```
|
|
948
|
-
*/
|
|
949
|
-
functionList(options?: FunctionListOptions & DecoderOption & RouteOption): Promise<ClusterResponse<FunctionListResponse>>;
|
|
950
|
-
/**
|
|
951
|
-
* Returns information about the function that's currently running and information about the
|
|
952
|
-
* available execution engines.
|
|
953
|
-
*
|
|
954
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
955
|
-
*
|
|
956
|
-
* @see {@link https://valkey.io/commands/function-stats/|valkey.io} for details.
|
|
957
|
-
* @remarks Since Valkey version 7.0.0.
|
|
958
|
-
*
|
|
959
|
-
* @param options - (Optional) See {@link DecoderOption} and {@link RouteOption}.
|
|
960
|
-
* @returns A `Record` with two keys:
|
|
961
|
-
* - `"running_script"` with information about the running script.
|
|
962
|
-
* - `"engines"` with information about available engines and their stats.
|
|
963
|
-
* - See example for more details.
|
|
964
|
-
*
|
|
965
|
-
* @example
|
|
966
|
-
* ```typescript
|
|
967
|
-
* const response = await client.functionStats("randomNode");
|
|
968
|
-
* console.log(response); // Output:
|
|
969
|
-
* // {
|
|
970
|
-
* // "running_script":
|
|
971
|
-
* // {
|
|
972
|
-
* // "name": "deep_thought",
|
|
973
|
-
* // "command": ["fcall", "deep_thought", "0"],
|
|
974
|
-
* // "duration_ms": 5008
|
|
975
|
-
* // },
|
|
976
|
-
* // "engines":
|
|
977
|
-
* // {
|
|
978
|
-
* // "LUA":
|
|
979
|
-
* // {
|
|
980
|
-
* // "libraries_count": 2,
|
|
981
|
-
* // "functions_count": 3
|
|
982
|
-
* // }
|
|
983
|
-
* // }
|
|
984
|
-
* // }
|
|
985
|
-
* // Output if no scripts running:
|
|
986
|
-
* // {
|
|
987
|
-
* // "running_script": null
|
|
988
|
-
* // "engines":
|
|
989
|
-
* // {
|
|
990
|
-
* // "LUA":
|
|
991
|
-
* // {
|
|
992
|
-
* // "libraries_count": 2,
|
|
993
|
-
* // "functions_count": 3
|
|
994
|
-
* // }
|
|
995
|
-
* // }
|
|
996
|
-
* // }
|
|
997
|
-
* ```
|
|
998
|
-
*/
|
|
999
|
-
functionStats(options?: RouteOption & DecoderOption): Promise<ClusterResponse<FunctionStatsSingleResponse>>;
|
|
1000
|
-
/**
|
|
1001
|
-
* Kills a function that is currently executing.
|
|
1002
|
-
* `FUNCTION KILL` terminates read-only functions only.
|
|
1003
|
-
*
|
|
1004
|
-
* @see {@link https://valkey.io/commands/function-kill/|valkey.io} for details.
|
|
1005
|
-
* @remarks Since Valkey version 7.0.0.
|
|
1006
|
-
*
|
|
1007
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1008
|
-
* @returns `"OK"` if function is terminated. Otherwise, throws an error.
|
|
1009
|
-
*
|
|
1010
|
-
* @example
|
|
1011
|
-
* ```typescript
|
|
1012
|
-
* await client.functionKill();
|
|
1013
|
-
* ```
|
|
1014
|
-
*/
|
|
1015
|
-
functionKill(options?: RouteOption): Promise<"OK">;
|
|
1016
|
-
/**
|
|
1017
|
-
* Returns the serialized payload of all loaded libraries.
|
|
1018
|
-
*
|
|
1019
|
-
* @see {@link https://valkey.io/commands/function-dump/|valkey.io} for details.
|
|
1020
|
-
* @remarks Since Valkey version 7.0.0.
|
|
1021
|
-
*
|
|
1022
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1023
|
-
* @returns The serialized payload of all loaded libraries.
|
|
1024
|
-
*
|
|
1025
|
-
* @example
|
|
1026
|
-
* ```typescript
|
|
1027
|
-
* const data = await client.functionDump();
|
|
1028
|
-
* // data can be used to restore loaded functions on any Valkey instance
|
|
1029
|
-
* ```
|
|
1030
|
-
*/
|
|
1031
|
-
functionDump(options?: RouteOption): Promise<ClusterResponse<Buffer>>;
|
|
1032
|
-
/**
|
|
1033
|
-
* Restores libraries from the serialized payload returned by {@link functionDump}.
|
|
1034
|
-
*
|
|
1035
|
-
* @see {@link https://valkey.io/commands/function-restore/|valkey.io} for details.
|
|
1036
|
-
* @remarks Since Valkey version 7.0.0.
|
|
1037
|
-
*
|
|
1038
|
-
* @param payload - The serialized data from {@link functionDump}.
|
|
1039
|
-
* @param options - (Optional) Additional parameters:
|
|
1040
|
-
* - (Optional) `policy`: a policy for handling existing libraries, see {@link FunctionRestorePolicy}.
|
|
1041
|
-
* {@link FunctionRestorePolicy.APPEND} is used by default.
|
|
1042
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
1043
|
-
* @returns `"OK"`.
|
|
1044
|
-
*
|
|
1045
|
-
* @example
|
|
1046
|
-
* ```typescript
|
|
1047
|
-
* await client.functionRestore(data, { policy: FunctionRestorePolicy.FLUSH, route: "allPrimaries" });
|
|
1048
|
-
* ```
|
|
1049
|
-
*/
|
|
1050
|
-
functionRestore(payload: Buffer, options?: {
|
|
1051
|
-
policy?: FunctionRestorePolicy;
|
|
1052
|
-
} & RouteOption): Promise<"OK">;
|
|
1053
|
-
/**
|
|
1054
|
-
* Deletes all the keys of all the existing databases. This command never fails.
|
|
1055
|
-
*
|
|
1056
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
1057
|
-
*
|
|
1058
|
-
* @see {@link https://valkey.io/commands/flushall/|valkey.io} for details.
|
|
1059
|
-
*
|
|
1060
|
-
* @param options - (Optional) Additional parameters:
|
|
1061
|
-
* - (Optional) `mode`: the flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
|
|
1062
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
1063
|
-
* @returns `OK`.
|
|
1064
|
-
*
|
|
1065
|
-
* @example
|
|
1066
|
-
* ```typescript
|
|
1067
|
-
* const result = await client.flushall(FlushMode.SYNC);
|
|
1068
|
-
* console.log(result); // Output: 'OK'
|
|
1069
|
-
* ```
|
|
1070
|
-
*/
|
|
1071
|
-
flushall(options?: {
|
|
1072
|
-
mode?: FlushMode;
|
|
1073
|
-
} & RouteOption): Promise<"OK">;
|
|
1074
|
-
/**
|
|
1075
|
-
* Deletes all the keys of the currently selected database. This command never fails.
|
|
1076
|
-
*
|
|
1077
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
1078
|
-
*
|
|
1079
|
-
* @see {@link https://valkey.io/commands/flushdb/|valkey.io} for details.
|
|
1080
|
-
*
|
|
1081
|
-
* @param options - (Optional) Additional parameters:
|
|
1082
|
-
* - (Optional) `mode`: the flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
|
|
1083
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
1084
|
-
* @returns `OK`.
|
|
1085
|
-
*
|
|
1086
|
-
* @example
|
|
1087
|
-
* ```typescript
|
|
1088
|
-
* const result = await client.flushdb(FlushMode.SYNC);
|
|
1089
|
-
* console.log(result); // Output: 'OK'
|
|
1090
|
-
* ```
|
|
1091
|
-
*/
|
|
1092
|
-
flushdb(options?: {
|
|
1093
|
-
mode?: FlushMode;
|
|
1094
|
-
} & RouteOption): Promise<"OK">;
|
|
1095
|
-
/**
|
|
1096
|
-
* Returns the number of keys in the database.
|
|
1097
|
-
*
|
|
1098
|
-
* The command will be routed to all nodes, unless `route` is provided.
|
|
1099
|
-
*
|
|
1100
|
-
* @see {@link https://valkey.io/commands/dbsize/|valkey.io} for details.
|
|
1101
|
-
*
|
|
1102
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1103
|
-
* @returns The number of keys in the database.
|
|
1104
|
-
* In the case of routing the query to multiple nodes, returns the aggregated number of keys across the different nodes.
|
|
1105
|
-
*
|
|
1106
|
-
* @example
|
|
1107
|
-
* ```typescript
|
|
1108
|
-
* const numKeys = await client.dbsize("allPrimaries");
|
|
1109
|
-
* console.log("Number of keys across all primary nodes: ", numKeys);
|
|
1110
|
-
* ```
|
|
1111
|
-
*/
|
|
1112
|
-
dbsize(options?: RouteOption): Promise<number>;
|
|
1113
|
-
/** Publish a message on pubsub channel.
|
|
1114
|
-
* This command aggregates PUBLISH and SPUBLISH commands functionalities.
|
|
1115
|
-
* The mode is selected using the 'sharded' parameter.
|
|
1116
|
-
* For both sharded and non-sharded mode, request is routed using hashed channel as key.
|
|
1117
|
-
*
|
|
1118
|
-
* @see {@link https://valkey.io/commands/publish} and {@link https://valkey.io/commands/spublish} for more details.
|
|
1119
|
-
*
|
|
1120
|
-
* @param message - Message to publish.
|
|
1121
|
-
* @param channel - Channel to publish the message on.
|
|
1122
|
-
* @param sharded - Use sharded pubsub mode. Available since Valkey version 7.0.
|
|
1123
|
-
* @returns - Number of subscriptions in primary node that received the message.
|
|
1124
|
-
*
|
|
1125
|
-
* @example
|
|
1126
|
-
* ```typescript
|
|
1127
|
-
* // Example usage of publish command
|
|
1128
|
-
* const result = await client.publish("Hi all!", "global-channel");
|
|
1129
|
-
* console.log(result); // Output: 1 - This message was posted to 1 subscription which is configured on primary node
|
|
1130
|
-
* ```
|
|
1131
|
-
*
|
|
1132
|
-
* @example
|
|
1133
|
-
* ```typescript
|
|
1134
|
-
* // Example usage of spublish command
|
|
1135
|
-
* const result = await client.publish("Hi all!", "global-channel", true);
|
|
1136
|
-
* console.log(result); // Output: 2 - Published 2 instances of "Hi to sharded channel1!" message on channel1 using sharded mode
|
|
1137
|
-
* ```
|
|
1138
|
-
*/
|
|
1139
|
-
publish(message: GlideString, channel: GlideString, sharded?: boolean): Promise<number>;
|
|
1140
|
-
/**
|
|
1141
|
-
* Lists the currently active shard channels.
|
|
1142
|
-
* The command is routed to all nodes, and aggregates the response to a single array.
|
|
1143
|
-
*
|
|
1144
|
-
* @see {@link https://valkey.io/commands/pubsub-shardchannels/|valkey.io} for details.
|
|
1145
|
-
*
|
|
1146
|
-
* @param options - (Optional) Additional parameters:
|
|
1147
|
-
* - (Optional) `pattern`: A glob-style pattern to match active shard channels.
|
|
1148
|
-
* If not provided, all active shard channels are returned.
|
|
1149
|
-
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
1150
|
-
* @returns A list of currently active shard channels matching the given pattern.
|
|
1151
|
-
* If no pattern is specified, all active shard channels are returned.
|
|
1152
|
-
*
|
|
1153
|
-
* @example
|
|
1154
|
-
* ```typescript
|
|
1155
|
-
* const allChannels = await client.pubsubShardchannels();
|
|
1156
|
-
* console.log(allChannels); // Output: ["channel1", "channel2"]
|
|
1157
|
-
*
|
|
1158
|
-
* const filteredChannels = await client.pubsubShardchannels("channel*");
|
|
1159
|
-
* console.log(filteredChannels); // Output: ["channel1", "channel2"]
|
|
1160
|
-
* ```
|
|
1161
|
-
*/
|
|
1162
|
-
pubsubShardChannels(options?: {
|
|
1163
|
-
pattern?: GlideString;
|
|
1164
|
-
} & DecoderOption): Promise<GlideString[]>;
|
|
1165
|
-
/**
|
|
1166
|
-
* Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified shard channels.
|
|
1167
|
-
*
|
|
1168
|
-
* @see {@link https://valkey.io/commands/pubsub-shardnumsub/|valkey.io} for details.
|
|
1169
|
-
* @remarks The command is routed to all nodes, and aggregates the response into a single list.
|
|
1170
|
-
*
|
|
1171
|
-
* @param channels - The list of shard channels to query for the number of subscribers.
|
|
1172
|
-
* @param options - (Optional) see {@link DecoderOption}.
|
|
1173
|
-
* @returns A list of the shard channel names and their numbers of subscribers.
|
|
1174
|
-
*
|
|
1175
|
-
* @example
|
|
1176
|
-
* ```typescript
|
|
1177
|
-
* const result1 = await client.pubsubShardnumsub(["channel1", "channel2"]);
|
|
1178
|
-
* console.log(result1); // Output:
|
|
1179
|
-
* // [{ channel: "channel1", numSub: 3}, { channel: "channel2", numSub: 5 }]
|
|
1180
|
-
*
|
|
1181
|
-
* const result2 = await client.pubsubShardnumsub([]);
|
|
1182
|
-
* console.log(result2); // Output: []
|
|
1183
|
-
* ```
|
|
1184
|
-
*/
|
|
1185
|
-
pubsubShardNumSub(channels: GlideString[], options?: DecoderOption): Promise<{
|
|
1186
|
-
channel: GlideString;
|
|
1187
|
-
numSub: number;
|
|
1188
|
-
}[]>;
|
|
1189
|
-
/**
|
|
1190
|
-
* Returns `UNIX TIME` of the last DB save timestamp or startup timestamp if no save
|
|
1191
|
-
* was made since then.
|
|
1192
|
-
*
|
|
1193
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
1194
|
-
*
|
|
1195
|
-
* @see {@link https://valkey.io/commands/lastsave/|valkey.io} for details.
|
|
1196
|
-
*
|
|
1197
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1198
|
-
* @returns `UNIX TIME` of the last DB save executed with success.
|
|
1199
|
-
*
|
|
1200
|
-
* @example
|
|
1201
|
-
* ```typescript
|
|
1202
|
-
* const timestamp = await client.lastsave();
|
|
1203
|
-
* console.log("Last DB save was done at " + timestamp);
|
|
1204
|
-
* ```
|
|
1205
|
-
*/
|
|
1206
|
-
lastsave(options?: RouteOption): Promise<ClusterResponse<number>>;
|
|
1207
|
-
/**
|
|
1208
|
-
* Returns a random existing key name.
|
|
1209
|
-
*
|
|
1210
|
-
* The command will be routed to all primary nodes, unless `route` is provided.
|
|
1211
|
-
*
|
|
1212
|
-
* @see {@link https://valkey.io/commands/randomkey/|valkey.io} for details.
|
|
1213
|
-
*
|
|
1214
|
-
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}.
|
|
1215
|
-
* @returns A random existing key name.
|
|
1216
|
-
*
|
|
1217
|
-
* @example
|
|
1218
|
-
* ```typescript
|
|
1219
|
-
* const result = await client.randomKey();
|
|
1220
|
-
* console.log(result); // Output: "key12" - "key12" is a random existing key name.
|
|
1221
|
-
* ```
|
|
1222
|
-
*/
|
|
1223
|
-
randomKey(options?: DecoderOption & RouteOption): Promise<GlideString | null>;
|
|
1224
|
-
/**
|
|
1225
|
-
* Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
1226
|
-
* automatically flush all previously watched keys.
|
|
1227
|
-
*
|
|
1228
|
-
* The command will be routed to all primary nodes, unless `route` is provided
|
|
1229
|
-
*
|
|
1230
|
-
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey Glide Wiki} for more details.
|
|
1231
|
-
*
|
|
1232
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1233
|
-
* @returns A simple `"OK"` response.
|
|
1234
|
-
*
|
|
1235
|
-
* @example
|
|
1236
|
-
* ```typescript
|
|
1237
|
-
* let response = await client.watch(["sampleKey"]);
|
|
1238
|
-
* console.log(response); // Output: "OK"
|
|
1239
|
-
* response = await client.unwatch();
|
|
1240
|
-
* console.log(response); // Output: "OK"
|
|
1241
|
-
* ```
|
|
1242
|
-
*/
|
|
1243
|
-
unwatch(options?: RouteOption): Promise<"OK">;
|
|
1244
|
-
/**
|
|
1245
|
-
* Invokes a Lua script with arguments.
|
|
1246
|
-
* This method simplifies the process of invoking scripts on a Valkey server by using an object that represents a Lua script.
|
|
1247
|
-
* The script loading, argument preparation, and execution will all be handled internally. If the script has not already been loaded,
|
|
1248
|
-
* it will be loaded automatically using the `SCRIPT LOAD` command. After that, it will be invoked using the `EVALSHA` command.
|
|
1249
|
-
*
|
|
1250
|
-
* The command will be routed to a random node, unless `route` is provided.
|
|
1251
|
-
*
|
|
1252
|
-
* @see {@link https://valkey.io/commands/script-load/|SCRIPT LOAD} and {@link https://valkey.io/commands/evalsha/|EVALSHA} on valkey.io for details.
|
|
1253
|
-
*
|
|
1254
|
-
* @param script - The Lua script to execute.
|
|
1255
|
-
* @param options - (Optional) Additional parameters:
|
|
1256
|
-
* - (Optional) `args`: the arguments for the script.
|
|
1257
|
-
* - (Optional) `decoder`: see {@link DecoderOption}.
|
|
1258
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
1259
|
-
* @returns A value that depends on the script that was executed.
|
|
1260
|
-
*
|
|
1261
|
-
* @example
|
|
1262
|
-
* ```typescript
|
|
1263
|
-
* const luaScript = new Script("return { ARGV[1] }");
|
|
1264
|
-
* const result = await client.invokeScript(luaScript, { args: ["bar"] });
|
|
1265
|
-
* console.log(result); // Output: ['bar']
|
|
1266
|
-
* ```
|
|
1267
|
-
*/
|
|
1268
|
-
invokeScriptWithRoute(script: Script, options?: {
|
|
1269
|
-
args?: GlideString[];
|
|
1270
|
-
} & DecoderOption & RouteOption): Promise<ClusterResponse<GlideReturnType>>;
|
|
1271
|
-
private createScriptInvocationWithRoutePromise;
|
|
1272
|
-
/**
|
|
1273
|
-
* Checks existence of scripts in the script cache by their SHA1 digest.
|
|
1274
|
-
*
|
|
1275
|
-
* @see {@link https://valkey.io/commands/script-exists/|valkey.io} for more details.
|
|
1276
|
-
*
|
|
1277
|
-
* @param sha1s - List of SHA1 digests of the scripts to check.
|
|
1278
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1279
|
-
* @returns A list of boolean values indicating the existence of each script.
|
|
1280
|
-
*
|
|
1281
|
-
* @example
|
|
1282
|
-
* ```typescript
|
|
1283
|
-
* console result = await client.scriptExists(["sha1_digest1", "sha1_digest2"]);
|
|
1284
|
-
* console.log(result); // Output: [true, false]
|
|
1285
|
-
* ```
|
|
1286
|
-
*/
|
|
1287
|
-
scriptExists(sha1s: GlideString[], options?: RouteOption): Promise<ClusterResponse<boolean[]>>;
|
|
1288
|
-
/**
|
|
1289
|
-
* Flushes the Lua scripts cache.
|
|
1290
|
-
*
|
|
1291
|
-
* @see {@link https://valkey.io/commands/script-flush/|valkey.io} for more details.
|
|
1292
|
-
*
|
|
1293
|
-
* @param options - (Optional) Additional parameters:
|
|
1294
|
-
* - (Optional) `mode`: the flushing mode, could be either {@link FlushMode.SYNC} or {@link FlushMode.ASYNC}.
|
|
1295
|
-
* - (Optional) `route`: see {@link RouteOption}.
|
|
1296
|
-
* @returns A simple `"OK"` response.
|
|
1297
|
-
*
|
|
1298
|
-
* @example
|
|
1299
|
-
* ```typescript
|
|
1300
|
-
* console result = await client.scriptFlush(FlushMode.SYNC);
|
|
1301
|
-
* console.log(result); // Output: "OK"
|
|
1302
|
-
* ```
|
|
1303
|
-
*/
|
|
1304
|
-
scriptFlush(options?: {
|
|
1305
|
-
mode?: FlushMode;
|
|
1306
|
-
} & RouteOption): Promise<"OK">;
|
|
1307
|
-
/**
|
|
1308
|
-
* Kills the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
1309
|
-
*
|
|
1310
|
-
* @see {@link https://valkey.io/commands/script-kill/|valkey.io} for more details.
|
|
1311
|
-
* @remarks The command is routed to all nodes, and aggregates the response to a single array.
|
|
1312
|
-
*
|
|
1313
|
-
* @param options - (Optional) See {@link RouteOption}.
|
|
1314
|
-
* @returns A simple `"OK"` response.
|
|
1315
|
-
*
|
|
1316
|
-
* @example
|
|
1317
|
-
* ```typescript
|
|
1318
|
-
* console result = await client.scriptKill();
|
|
1319
|
-
* console.log(result); // Output: "OK"
|
|
1320
|
-
* ```
|
|
1321
|
-
*/
|
|
1322
|
-
scriptKill(options?: RouteOption): Promise<"OK">;
|
|
1323
|
-
}
|