@valkey/valkey-glide 2.4.2-rc2 → 2.5.0-rc2

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.
@@ -6,7 +6,8 @@ import { Buffer, Writer } from "protobufjs/minimal";
6
6
  import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
7
7
  BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
8
8
  BitOffsetOptions, BitwiseOperation, Boundary, ClientSideCache, CompressionConfiguration, ConnectionError, ExpireOptions, GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
9
- GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, GlideClientConfiguration, GlideClusterClientConfiguration, HExpireOptions, HGetExOptions, HScanOptions, HSetExOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, RangeByIndex, RangeByLex, RangeByScore, RequestError, RestoreOptions, Routes, ScoreFilter, Script, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ValkeyError, ZAddOptions, ZScanOptions } from ".";
9
+ GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, GlideClientConfiguration, GlideClusterClientConfiguration, HExpireOptions, HGetExOptions, HScanOptions, HSetExOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, // eslint-disable-line @typescript-eslint/no-unused-vars
10
+ MigrateOptions, RangeByIndex, RangeByLex, RangeByScore, RequestError, RestoreOptions, Routes, ScoreFilter, Script, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ValkeyError, ZAddOptions, ZScanOptions } from ".";
10
11
  import { command_request, connection_request, response } from "../build-ts/ProtobufMessage";
11
12
  type PromiseFunction = (value?: any) => void;
12
13
  type ErrorFunction = (error: ValkeyError) => void;
@@ -514,6 +515,60 @@ export interface BaseClientConfiguration {
514
515
  * ```
515
516
  */
516
517
  clientSideCache?: ClientSideCache;
518
+ /**
519
+ * Optional callback for resolving server addresses before connection.
520
+ *
521
+ * When provided, this callback will be invoked for each configured address during connection
522
+ * establishment and during cluster topology refreshes. The callback receives the configured
523
+ * host and port, and should return a tuple `[resolvedHost, resolvedPort]` with the actual
524
+ * address to use for the connection.
525
+ *
526
+ * Use cases:
527
+ * - Custom DNS resolution for service discovery
528
+ * - Address translation for proxy setups
529
+ * - Dynamic endpoint resolution for cloud environments
530
+ *
531
+ * If the resolver throws an exception or returns an invalid value, the original address
532
+ * is used as a fallback.
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * const config: BaseClientConfiguration = {
537
+ * addresses: [{ host: "internal-service", port: 9999 }],
538
+ * addressResolver: (host, port) => {
539
+ * if (host === "internal-service") {
540
+ * return ["10.0.0.5", 6379];
541
+ * }
542
+ * return [host, port];
543
+ * },
544
+ * };
545
+ * ```
546
+ */
547
+ addressResolver?: (host: string, port: number) => [string, number];
548
+ /**
549
+ * Configuration for the client-wide circuit breaker.
550
+ * When set, enables the circuit breaker which detects sustained error rates
551
+ * and rejects requests before they enter the core.
552
+ * If not set (undefined), the circuit breaker is disabled.
553
+ */
554
+ clientCircuitBreaker?: ClientCircuitBreakerConfiguration;
555
+ }
556
+ /**
557
+ * Configuration for the client-wide circuit breaker.
558
+ */
559
+ export interface ClientCircuitBreakerConfiguration {
560
+ /** Sliding window duration in milliseconds for error rate calculation. Default: 10000. */
561
+ windowSizeMs?: number;
562
+ /** Error rate (0.0-1.0) within the window to trip the breaker. Default: 0.5. */
563
+ failureRateThreshold?: number;
564
+ /** Minimum errors within window before rate is evaluated. Default: 50. */
565
+ minErrors?: number;
566
+ /** Time in milliseconds in Open state before allowing a probe. Default: 5000. */
567
+ openTimeoutMs?: number;
568
+ /** Whether timeouts count toward tripping. Default: false. */
569
+ countTimeouts?: boolean;
570
+ /** Consecutive successful probes needed before closing. Default: 3. */
571
+ consecutiveSuccesses?: number;
517
572
  }
518
573
  /**
519
574
  * Represents advanced configuration settings for a client, including connection-related options.
@@ -655,6 +710,7 @@ export declare class BaseClient {
655
710
  private pendingPushNotification;
656
711
  private readonly inflightRequestsLimit;
657
712
  private config;
713
+ private addressResolverKey;
658
714
  protected configurePubsub(options: GlideClusterClientConfiguration | GlideClientConfiguration, configuration: connection_request.IConnectionRequest): void;
659
715
  private handleReadData;
660
716
  protected toProtobufRoute(route: Routes | undefined): command_request.Routes | undefined;
@@ -1114,6 +1170,34 @@ export declare class BaseClient {
1114
1170
  destinationDB?: number;
1115
1171
  replace?: boolean;
1116
1172
  }): Promise<boolean>;
1173
+ /**
1174
+ * Atomically transfers a key from a source Valkey instance to a destination Valkey instance.
1175
+ * Once the key is successfully transferred, it is deleted from the source instance
1176
+ * unless `copy` is set to `true` in options.
1177
+ *
1178
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
1179
+ *
1180
+ * @param host - The host of the destination Valkey instance.
1181
+ * @param port - The port of the destination Valkey instance.
1182
+ * @param key - The key to migrate.
1183
+ * @param destinationDB - The database index on the destination instance.
1184
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
1185
+ * @param options - Optional migration options.
1186
+ * @returns `"OK"` on success, or `"NOKEY"` if the key does not exist.
1187
+ *
1188
+ * @example
1189
+ * ```typescript
1190
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000);
1191
+ * console.log(result); // Output: "OK" - "mykey" was migrated to the destination instance.
1192
+ * ```
1193
+ * @example
1194
+ * ```typescript
1195
+ * // Migrate with copy (keep source key) and replace (overwrite destination)
1196
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000, { copy: true, replace: true });
1197
+ * console.log(result); // Output: "OK" - "mykey" was copied to the destination instance.
1198
+ * ```
1199
+ */
1200
+ migrate(host: string, port: number, key: GlideString, destinationDB: number, timeout: number, options?: MigrateOptions): Promise<string>;
1117
1201
  /** Decrements the number stored at `key` by one. If `key` does not exist, it is set to 0 before performing the operation.
1118
1202
  *
1119
1203
  * @see {@link https://valkey.io/commands/decr/|valkey.io} for details.
@@ -6238,6 +6322,22 @@ export declare class BaseClient {
6238
6322
  * ```
6239
6323
  */
6240
6324
  wait(numreplicas: number, timeout: number): Promise<number>;
6325
+ /**
6326
+ * Resets the connection state.
6327
+ *
6328
+ * @see {@link https://valkey.io/commands/reset/|valkey.io} for more details.
6329
+ *
6330
+ * @remarks Resets the database index, client name, protocol, and pubsub subscriptions.
6331
+ *
6332
+ * @returns "RESET" when the connection state is successfully reset.
6333
+ *
6334
+ * @example
6335
+ * ```typescript
6336
+ * const result = await client.reset();
6337
+ * console.log(result); // Output: "RESET"
6338
+ * ```
6339
+ */
6340
+ reset(): Promise<"RESET">;
6241
6341
  /**
6242
6342
  * Overwrites part of the string stored at `key`, starting at the specified byte `offset`,
6243
6343
  * for the entire length of `value`. If the `offset` is larger than the current length of the string at `key`,
@@ -212,6 +212,9 @@ function getRequestErrorClass(type) {
212
212
  if (type === ProtobufMessage_1.response.RequestErrorType.Timeout) {
213
213
  return _1.TimeoutError;
214
214
  }
215
+ if (type === ProtobufMessage_1.response.RequestErrorType.CircuitBreakerOpen) {
216
+ return _1.CircuitBreakerError;
217
+ }
215
218
  if (type === ProtobufMessage_1.response.RequestErrorType.Unspecified) {
216
219
  return _1.RequestError;
217
220
  }
@@ -234,6 +237,7 @@ class BaseClient {
234
237
  pendingPushNotification = [];
235
238
  inflightRequestsLimit;
236
239
  config;
240
+ addressResolverKey;
237
241
  configurePubsub(options, configuration) {
238
242
  if (options.pubsubSubscriptions) {
239
243
  if (options.protocol == ProtocolVersion.RESP2) {
@@ -1228,6 +1232,36 @@ class BaseClient {
1228
1232
  async copy(source, destination, options) {
1229
1233
  return this.createWritePromise((0, _1.createCopy)(source, destination, options));
1230
1234
  }
1235
+ /**
1236
+ * Atomically transfers a key from a source Valkey instance to a destination Valkey instance.
1237
+ * Once the key is successfully transferred, it is deleted from the source instance
1238
+ * unless `copy` is set to `true` in options.
1239
+ *
1240
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
1241
+ *
1242
+ * @param host - The host of the destination Valkey instance.
1243
+ * @param port - The port of the destination Valkey instance.
1244
+ * @param key - The key to migrate.
1245
+ * @param destinationDB - The database index on the destination instance.
1246
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
1247
+ * @param options - Optional migration options.
1248
+ * @returns `"OK"` on success, or `"NOKEY"` if the key does not exist.
1249
+ *
1250
+ * @example
1251
+ * ```typescript
1252
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000);
1253
+ * console.log(result); // Output: "OK" - "mykey" was migrated to the destination instance.
1254
+ * ```
1255
+ * @example
1256
+ * ```typescript
1257
+ * // Migrate with copy (keep source key) and replace (overwrite destination)
1258
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000, { copy: true, replace: true });
1259
+ * console.log(result); // Output: "OK" - "mykey" was copied to the destination instance.
1260
+ * ```
1261
+ */
1262
+ async migrate(host, port, key, destinationDB, timeout, options) {
1263
+ return this.createWritePromise((0, _1.createMigrate)(host, port, key, destinationDB, timeout, options));
1264
+ }
1231
1265
  /** Decrements the number stored at `key` by one. If `key` does not exist, it is set to 0 before performing the operation.
1232
1266
  *
1233
1267
  * @see {@link https://valkey.io/commands/decr/|valkey.io} for details.
@@ -6701,6 +6735,26 @@ class BaseClient {
6701
6735
  async wait(numreplicas, timeout) {
6702
6736
  return this.createWritePromise((0, _1.createWait)(numreplicas, timeout));
6703
6737
  }
6738
+ /**
6739
+ * Resets the connection state.
6740
+ *
6741
+ * @see {@link https://valkey.io/commands/reset/|valkey.io} for more details.
6742
+ *
6743
+ * @remarks Resets the database index, client name, protocol, and pubsub subscriptions.
6744
+ *
6745
+ * @returns "RESET" when the connection state is successfully reset.
6746
+ *
6747
+ * @example
6748
+ * ```typescript
6749
+ * const result = await client.reset();
6750
+ * console.log(result); // Output: "RESET"
6751
+ * ```
6752
+ */
6753
+ async reset() {
6754
+ return this.createWritePromise((0, _1.createReset)(), {
6755
+ decoder: Decoder.String,
6756
+ });
6757
+ }
6704
6758
  /**
6705
6759
  * Overwrites part of the string stored at `key`, starting at the specified byte `offset`,
6706
6760
  * for the entire length of `value`. If the `offset` is larger than the current length of the string at `key`,
@@ -7054,6 +7108,7 @@ class BaseClient {
7054
7108
  entryTtlMs: cache.entryTtlMs,
7055
7109
  evictionPolicy: cache.evictionPolicy,
7056
7110
  enableMetrics: cache.enableMetrics,
7111
+ serverAssisted: cache.serverAssisted,
7057
7112
  });
7058
7113
  }
7059
7114
  const request = {
@@ -7078,6 +7133,35 @@ class BaseClient {
7078
7133
  (0, _1.validateCompressionConfiguration)(options.compression);
7079
7134
  request.compressionConfig = (0, _1.compressionConfigToProtobuf)(options.compression, ProtobufMessage_1.connection_request);
7080
7135
  }
7136
+ if (options.clientCircuitBreaker) {
7137
+ const cb = options.clientCircuitBreaker;
7138
+ if (cb.windowSizeMs !== undefined && cb.windowSizeMs <= 0) {
7139
+ throw new _1.ConfigurationError("windowSizeMs must be positive");
7140
+ }
7141
+ if (cb.failureRateThreshold !== undefined &&
7142
+ (cb.failureRateThreshold <= 0.0 ||
7143
+ cb.failureRateThreshold > 1.0)) {
7144
+ throw new _1.ConfigurationError("failureRateThreshold must be between 0.0 (exclusive) and 1.0 (inclusive)");
7145
+ }
7146
+ if (cb.minErrors !== undefined && cb.minErrors <= 0) {
7147
+ throw new _1.ConfigurationError("minErrors must be positive");
7148
+ }
7149
+ if (cb.openTimeoutMs !== undefined && cb.openTimeoutMs <= 0) {
7150
+ throw new _1.ConfigurationError("openTimeoutMs must be positive");
7151
+ }
7152
+ if (cb.consecutiveSuccesses !== undefined &&
7153
+ cb.consecutiveSuccesses <= 0) {
7154
+ throw new _1.ConfigurationError("consecutiveSuccesses must be positive");
7155
+ }
7156
+ request.clientCircuitBreaker = {
7157
+ windowSizeMs: cb.windowSizeMs,
7158
+ failureRateThreshold: cb.failureRateThreshold,
7159
+ minErrors: cb.minErrors,
7160
+ openTimeoutMs: cb.openTimeoutMs,
7161
+ countTimeouts: cb.countTimeouts,
7162
+ consecutiveSuccesses: cb.consecutiveSuccesses,
7163
+ };
7164
+ }
7081
7165
  return request;
7082
7166
  }
7083
7167
  /**
@@ -7120,12 +7204,29 @@ class BaseClient {
7120
7204
  */
7121
7205
  connectToServer(options) {
7122
7206
  return new Promise((resolve, reject) => {
7207
+ // Register address resolver in the global registry before sending
7208
+ // the connection request, so the socket listener can pick it up.
7209
+ if (options.addressResolver) {
7210
+ this.addressResolverKey = (0, _1.registerAddressResolver)(options.addressResolver);
7211
+ }
7123
7212
  this.promiseCallbackFunctions[0] = [
7124
7213
  resolve,
7125
- reject,
7214
+ (err) => {
7215
+ // Clean up the resolver from the registry if connection fails
7216
+ if (this.addressResolverKey) {
7217
+ (0, _1.removeAddressResolver)(this.addressResolverKey);
7218
+ this.addressResolverKey = undefined;
7219
+ }
7220
+ reject(err);
7221
+ },
7126
7222
  options?.defaultDecoder,
7127
7223
  ];
7128
- const message = ProtobufMessage_1.connection_request.ConnectionRequest.create(this.createClientRequest(options));
7224
+ const request = this.createClientRequest(options);
7225
+ // Set the address resolver key in the protobuf request
7226
+ if (this.addressResolverKey) {
7227
+ request.addressResolverKey = this.addressResolverKey;
7228
+ }
7229
+ const message = ProtobufMessage_1.connection_request.ConnectionRequest.create(request);
7129
7230
  this.writeOrBufferRequest(message, (message, writer) => {
7130
7231
  ProtobufMessage_1.connection_request.ConnectionRequest.encodeDelimited(message, writer);
7131
7232
  });
@@ -7145,6 +7246,11 @@ class BaseClient {
7145
7246
  this.pubsubFutures.forEach(([, reject]) => {
7146
7247
  reject(new _1.ClosingError(errorMessage || ""));
7147
7248
  });
7249
+ // Clean up address resolver from the global registry
7250
+ if (this.addressResolverKey) {
7251
+ (0, _1.removeAddressResolver)(this.addressResolverKey);
7252
+ this.addressResolverKey = undefined;
7253
+ }
7148
7254
  _1.Logger.log("info", "Client lifetime", "disposing of client");
7149
7255
  this.socket.end();
7150
7256
  }
@@ -13,7 +13,7 @@ FunctionRestorePolicy, // eslint-disable-line @typescript-eslint/no-unused-vars
13
13
  GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
14
14
  GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, // eslint-disable-line @typescript-eslint/no-unused-vars
15
15
  GlideRecord, GlideString, HExpireOptions, HGetExOptions, HScanOptions, HSetExOptions, HashDataType, InfoOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, LolwutOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
16
- RangeByIndex, RangeByLex, RangeByScore, // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ MigrateOptions, RangeByIndex, RangeByLex, RangeByScore, // eslint-disable-line @typescript-eslint/no-unused-vars
17
17
  RestoreOptions, Score, ScoreFilter, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ZAddOptions, ZScanOptions } from ".";
18
18
  import { command_request } from "../build-ts/ProtobufMessage";
19
19
  /**
@@ -141,6 +141,21 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
141
141
  destinationDB?: number;
142
142
  replace?: boolean;
143
143
  }): T;
144
+ /**
145
+ * Atomically transfers a key from a source Valkey instance to a destination Valkey instance.
146
+ *
147
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
148
+ *
149
+ * @param host - The host of the destination Valkey instance.
150
+ * @param port - The port of the destination Valkey instance.
151
+ * @param key - The key to migrate.
152
+ * @param destinationDB - The database index on the destination instance.
153
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
154
+ * @param options - Optional migration options.
155
+ *
156
+ * Command Response - "OK" on success, or "NOKEY" if the key was not found.
157
+ */
158
+ migrate(host: string, port: number, key: GlideString, destinationDB: number, timeout: number, options?: MigrateOptions): T;
144
159
  /**
145
160
  * Gets information and statistics about the server.
146
161
  *
@@ -2486,6 +2501,17 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
2486
2501
  * current connection.
2487
2502
  */
2488
2503
  wait(numreplicas: number, timeout: number): T;
2504
+ /**
2505
+ * Resets the connection state.
2506
+ *
2507
+ * @see {@link https://valkey.io/commands/reset/|valkey.io} for more details.
2508
+ *
2509
+ * @remarks RESET cannot be used inside an atomic batch (MULTI/EXEC transaction).
2510
+ * Use a non-atomic batch (`new Batch(false)`) instead.
2511
+ *
2512
+ * Command Response - "RESET" when the connection state is successfully reset.
2513
+ */
2514
+ reset(): T;
2489
2515
  /**
2490
2516
  * Invokes a previously loaded function.
2491
2517
  *
@@ -3128,6 +3154,22 @@ export declare class Batch extends BaseBatch<Batch> {
3128
3154
  * Command Response - A simple `"OK"` response.
3129
3155
  */
3130
3156
  select(index: number): Batch;
3157
+ /**
3158
+ * Atomically transfers one or more keys from a source Valkey instance to a destination Valkey instance.
3159
+ * Extends {@link BaseBatch.migrate} with multi-key support using the KEYS subcommand.
3160
+ *
3161
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
3162
+ *
3163
+ * @param host - The host of the destination Valkey instance.
3164
+ * @param port - The port of the destination Valkey instance.
3165
+ * @param key - The key to migrate, or an array of keys to migrate.
3166
+ * @param destinationDB - The database index on the destination instance.
3167
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
3168
+ * @param options - Optional migration options.
3169
+ *
3170
+ * Command Response - "OK" on success, or "NOKEY" if no keys were found.
3171
+ */
3172
+ migrate(host: string, port: number, key: GlideString | GlideString[], destinationDB: number, timeout: number, options?: MigrateOptions): Batch;
3131
3173
  /** Publish a message on pubsub channel.
3132
3174
  *
3133
3175
  * @see {@link https://valkey.io/commands/publish/|valkey.io} for more details.
package/build-ts/Batch.js CHANGED
@@ -160,6 +160,23 @@ class BaseBatch {
160
160
  copy(source, destination, options) {
161
161
  return this.addAndReturn((0, _1.createCopy)(source, destination, options));
162
162
  }
163
+ /**
164
+ * Atomically transfers a key from a source Valkey instance to a destination Valkey instance.
165
+ *
166
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
167
+ *
168
+ * @param host - The host of the destination Valkey instance.
169
+ * @param port - The port of the destination Valkey instance.
170
+ * @param key - The key to migrate.
171
+ * @param destinationDB - The database index on the destination instance.
172
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
173
+ * @param options - Optional migration options.
174
+ *
175
+ * Command Response - "OK" on success, or "NOKEY" if the key was not found.
176
+ */
177
+ migrate(host, port, key, destinationDB, timeout, options) {
178
+ return this.addAndReturn((0, _1.createMigrate)(host, port, key, destinationDB, timeout, options));
179
+ }
163
180
  /**
164
181
  * Gets information and statistics about the server.
165
182
  *
@@ -2841,6 +2858,19 @@ class BaseBatch {
2841
2858
  wait(numreplicas, timeout) {
2842
2859
  return this.addAndReturn((0, _1.createWait)(numreplicas, timeout));
2843
2860
  }
2861
+ /**
2862
+ * Resets the connection state.
2863
+ *
2864
+ * @see {@link https://valkey.io/commands/reset/|valkey.io} for more details.
2865
+ *
2866
+ * @remarks RESET cannot be used inside an atomic batch (MULTI/EXEC transaction).
2867
+ * Use a non-atomic batch (`new Batch(false)`) instead.
2868
+ *
2869
+ * Command Response - "RESET" when the connection state is successfully reset.
2870
+ */
2871
+ reset() {
2872
+ return this.addAndReturn((0, _1.createReset)());
2873
+ }
2844
2874
  /**
2845
2875
  * Invokes a previously loaded function.
2846
2876
  *
@@ -3561,6 +3591,24 @@ class Batch extends BaseBatch {
3561
3591
  select(index) {
3562
3592
  return this.addAndReturn((0, _1.createSelect)(index));
3563
3593
  }
3594
+ /**
3595
+ * Atomically transfers one or more keys from a source Valkey instance to a destination Valkey instance.
3596
+ * Extends {@link BaseBatch.migrate} with multi-key support using the KEYS subcommand.
3597
+ *
3598
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
3599
+ *
3600
+ * @param host - The host of the destination Valkey instance.
3601
+ * @param port - The port of the destination Valkey instance.
3602
+ * @param key - The key to migrate, or an array of keys to migrate.
3603
+ * @param destinationDB - The database index on the destination instance.
3604
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
3605
+ * @param options - Optional migration options.
3606
+ *
3607
+ * Command Response - "OK" on success, or "NOKEY" if no keys were found.
3608
+ */
3609
+ migrate(host, port, key, destinationDB, timeout, options) {
3610
+ return this.addAndReturn((0, _1.createMigrate)(host, port, key, destinationDB, timeout, options));
3611
+ }
3564
3612
  /** Publish a message on pubsub channel.
3565
3613
  *
3566
3614
  * @see {@link https://valkey.io/commands/publish/|valkey.io} for more details.
@@ -26,6 +26,14 @@ export interface ClientSideCacheConfig {
26
26
  * Defaults to false if not specified.
27
27
  */
28
28
  enableMetrics?: boolean;
29
+ /**
30
+ * Whether to enable server-assisted client-side caching.
31
+ *
32
+ * When enabled, GLIDE sends CLIENT TRACKING ON BCAST during connection setup
33
+ * and the server sends invalidation messages when tracked keys are modified.
34
+ * Requires RESP3 protocol. Defaults to false if not specified.
35
+ */
36
+ serverAssisted?: boolean;
29
37
  }
30
38
  /**
31
39
  * Optional configuration options for the static create method.
@@ -39,6 +47,10 @@ export interface ClientSideCacheOptions {
39
47
  * Whether to enable metrics collection for this cache.
40
48
  */
41
49
  enableMetrics?: boolean;
50
+ /**
51
+ * Whether to enable server-assisted client-side caching.
52
+ */
53
+ serverAssisted?: boolean;
42
54
  }
43
55
  /**
44
56
  * Configuration class for client-side caching.
@@ -79,6 +91,10 @@ export declare class ClientSideCache {
79
91
  * Whether metrics collection is enabled for this cache.
80
92
  */
81
93
  readonly enableMetrics: boolean;
94
+ /**
95
+ * Whether server-assisted client-side caching is enabled.
96
+ */
97
+ readonly serverAssisted: boolean;
82
98
  /**
83
99
  * Creates a new ClientSideCache instance.
84
100
  *
@@ -49,6 +49,10 @@ class ClientSideCache {
49
49
  * Whether metrics collection is enabled for this cache.
50
50
  */
51
51
  enableMetrics;
52
+ /**
53
+ * Whether server-assisted client-side caching is enabled.
54
+ */
55
+ serverAssisted;
52
56
  /**
53
57
  * Creates a new ClientSideCache instance.
54
58
  *
@@ -68,6 +72,7 @@ class ClientSideCache {
68
72
  this.entryTtlMs = config.entryTtlMs;
69
73
  this.evictionPolicy = config.evictionPolicy;
70
74
  this.enableMetrics = config.enableMetrics ?? false;
75
+ this.serverAssisted = config.serverAssisted ?? false;
71
76
  }
72
77
  /**
73
78
  * Factory method to create a ClientSideCache with auto-generated cache ID.
@@ -97,6 +102,7 @@ class ClientSideCache {
97
102
  entryTtlMs,
98
103
  evictionPolicy: options?.evictionPolicy,
99
104
  enableMetrics: options?.enableMetrics,
105
+ serverAssisted: options?.serverAssisted,
100
106
  });
101
107
  }
102
108
  }