@valkey/valkey-glide 2.0.0 → 2.1.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,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  return (mod && mod.__esModule) ? mod : { "default": mod };
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TimeUnit = exports.ScoreFilter = exports.SortOrder = exports.GeoUnit = exports.ConditionalChange = exports.FlushMode = exports.BitmapIndexType = exports.FunctionRestorePolicy = exports.InsertPosition = exports.InfBoundary = exports.UpdateByScore = exports.ExpireOptions = exports.ListDirection = exports.BitFieldOverflow = exports.BitOverflowControl = exports.BitFieldIncrBy = exports.BitFieldSet = exports.BitFieldGet = exports.BitOffsetMultiplier = exports.BitOffset = exports.UnsignedEncoding = exports.SignedEncoding = exports.BitwiseOperation = exports.InfoOptions = void 0;
9
+ exports.TimeUnit = exports.ScoreFilter = exports.SortOrder = exports.GeoUnit = exports.HashExpirationCondition = exports.HashFieldConditionalChange = exports.ConditionalChange = exports.FlushMode = exports.BitmapIndexType = exports.FunctionRestorePolicy = exports.InsertPosition = exports.InfBoundary = exports.UpdateByScore = exports.ExpireOptions = exports.ListDirection = exports.BitFieldOverflow = exports.BitOverflowControl = exports.BitFieldIncrBy = exports.BitFieldSet = exports.BitFieldGet = exports.BitOffsetMultiplier = exports.BitOffset = exports.UnsignedEncoding = exports.SignedEncoding = exports.BitwiseOperation = exports.InfoOptions = void 0;
10
10
  exports.parseInfoResponse = parseInfoResponse;
11
11
  exports.createGet = createGet;
12
12
  exports.createGetDel = createGetDel;
@@ -33,6 +33,17 @@ exports.convertFieldsAndValuesToHashDataType = convertFieldsAndValuesToHashDataT
33
33
  exports.createHSet = createHSet;
34
34
  exports.createHKeys = createHKeys;
35
35
  exports.createHSetNX = createHSetNX;
36
+ exports.createHSetEx = createHSetEx;
37
+ exports.createHGetEx = createHGetEx;
38
+ exports.createHExpire = createHExpire;
39
+ exports.createHPersist = createHPersist;
40
+ exports.createHPExpire = createHPExpire;
41
+ exports.createHExpireAt = createHExpireAt;
42
+ exports.createHPExpireAt = createHPExpireAt;
43
+ exports.createHTtl = createHTtl;
44
+ exports.createHPTtl = createHPTtl;
45
+ exports.createHExpireTime = createHExpireTime;
46
+ exports.createHPExpireTime = createHPExpireTime;
36
47
  exports.createDecr = createDecr;
37
48
  exports.createDecrBy = createDecrBy;
38
49
  exports.createBitOp = createBitOp;
@@ -549,6 +560,179 @@ function createHKeys(key) {
549
560
  function createHSetNX(key, field, value) {
550
561
  return createCommand(RequestType.HSetNX, [key, field, value]);
551
562
  }
563
+ /**
564
+ * @internal
565
+ */
566
+ function createHSetEx(key, fieldValueMap, options) {
567
+ const args = [key];
568
+ // Add field conditional change options (FNX | FXX)
569
+ if (options?.fieldConditionalChange) {
570
+ args.push(options.fieldConditionalChange);
571
+ }
572
+ // Add expiry options (EX | PX | EXAT | PXAT | KEEPTTL)
573
+ // Note: PERSIST is not supported by HSETEX
574
+ if (options?.expiry) {
575
+ if (options.expiry === "KEEPTTL") {
576
+ args.push("KEEPTTL");
577
+ }
578
+ else {
579
+ // Validate that count is an integer
580
+ if (!Number.isInteger(options.expiry.count)) {
581
+ throw new Error(`HSETEX received expiry '${JSON.stringify(options.expiry)}'. Count must be an integer`);
582
+ }
583
+ args.push(options.expiry.type, options.expiry.count.toString());
584
+ }
585
+ }
586
+ // Only add FIELDS keyword and field count if fieldValueMap is not empty
587
+ if (fieldValueMap.length > 0) {
588
+ args.push("FIELDS", fieldValueMap.length.toString());
589
+ // Add field-value pairs
590
+ fieldValueMap.forEach((fieldValueObject) => {
591
+ args.push(fieldValueObject.field, fieldValueObject.value);
592
+ });
593
+ }
594
+ return createCommand(RequestType.HSetEx, args);
595
+ }
596
+ /**
597
+ * @internal
598
+ */
599
+ function createHGetEx(key, fields, options) {
600
+ const args = [key];
601
+ // Add expiry options (EX | PX | EXAT | PXAT | PERSIST)
602
+ // Note: HGETEX does not support KEEPTTL
603
+ if (options?.expiry) {
604
+ if (options.expiry === "PERSIST") {
605
+ args.push("PERSIST");
606
+ }
607
+ else {
608
+ // Validate that count is an integer
609
+ if (!Number.isInteger(options.expiry.count)) {
610
+ throw new Error(`HGETEX received expiry '${JSON.stringify(options.expiry)}'. Count must be an integer`);
611
+ }
612
+ args.push(options.expiry.type, options.expiry.count.toString());
613
+ }
614
+ }
615
+ // Add FIELDS keyword and field count - always required when fields parameter exists
616
+ args.push("FIELDS", fields.length.toString());
617
+ // Add field names
618
+ args.push(...fields);
619
+ return createCommand(RequestType.HGetEx, args);
620
+ }
621
+ /**
622
+ * @internal
623
+ */
624
+ function createHExpire(key, seconds, fields, options) {
625
+ const args = [key, seconds.toString()];
626
+ // Add condition options (NX | XX | GT | LT)
627
+ if (options?.condition) {
628
+ args.push(options.condition);
629
+ }
630
+ // Add FIELDS keyword and field count - always required when fields parameter exists
631
+ args.push("FIELDS", fields.length.toString());
632
+ // Add field names
633
+ args.push(...fields);
634
+ return createCommand(RequestType.HExpire, args);
635
+ }
636
+ /**
637
+ * @internal
638
+ */
639
+ function createHPersist(key, fields) {
640
+ const args = [key];
641
+ // Add FIELDS keyword and field count - always required when fields parameter exists
642
+ args.push("FIELDS", fields.length.toString());
643
+ // Add field names
644
+ args.push(...fields);
645
+ return createCommand(RequestType.HPersist, args);
646
+ }
647
+ /**
648
+ * @internal
649
+ */
650
+ function createHPExpire(key, milliseconds, fields, options) {
651
+ const args = [key, milliseconds.toString()];
652
+ // Add condition options (NX | XX | GT | LT)
653
+ if (options?.condition) {
654
+ args.push(options.condition);
655
+ }
656
+ // Add FIELDS keyword and field count - always required when fields parameter exists
657
+ args.push("FIELDS", fields.length.toString());
658
+ // Add field names
659
+ args.push(...fields);
660
+ return createCommand(RequestType.HPExpire, args);
661
+ }
662
+ /**
663
+ * @internal
664
+ */
665
+ function createHExpireAt(key, unixTimestampSeconds, fields, options) {
666
+ const args = [key, unixTimestampSeconds.toString()];
667
+ // Add condition options (NX | XX | GT | LT)
668
+ if (options?.condition) {
669
+ args.push(options.condition);
670
+ }
671
+ // Add FIELDS keyword and field count - always required when fields parameter exists
672
+ args.push("FIELDS", fields.length.toString());
673
+ // Add field names
674
+ args.push(...fields);
675
+ return createCommand(RequestType.HExpireAt, args);
676
+ }
677
+ /**
678
+ * @internal
679
+ */
680
+ function createHPExpireAt(key, unixTimestampMilliseconds, fields, options) {
681
+ const args = [key, unixTimestampMilliseconds.toString()];
682
+ // Add condition options (NX | XX | GT | LT)
683
+ if (options?.condition) {
684
+ args.push(options.condition);
685
+ }
686
+ // Add FIELDS keyword and field count - always required when fields parameter exists
687
+ args.push("FIELDS", fields.length.toString());
688
+ // Add field names
689
+ args.push(...fields);
690
+ return createCommand(RequestType.HPExpireAt, args);
691
+ }
692
+ /**
693
+ * @internal
694
+ */
695
+ function createHTtl(key, fields) {
696
+ const args = [key];
697
+ // Add FIELDS keyword and field count - always required when fields parameter exists
698
+ args.push("FIELDS", fields.length.toString());
699
+ // Add field names
700
+ args.push(...fields);
701
+ return createCommand(RequestType.HTtl, args);
702
+ }
703
+ /**
704
+ * @internal
705
+ */
706
+ function createHPTtl(key, fields) {
707
+ const args = [key];
708
+ // Add FIELDS keyword and field count - always required when fields parameter exists
709
+ args.push("FIELDS", fields.length.toString());
710
+ // Add field names
711
+ args.push(...fields);
712
+ return createCommand(RequestType.HPTtl, args);
713
+ }
714
+ /**
715
+ * @internal
716
+ */
717
+ function createHExpireTime(key, fields) {
718
+ const args = [key];
719
+ // Add FIELDS keyword and field count - always required when fields parameter exists
720
+ args.push("FIELDS", fields.length.toString());
721
+ // Add field names
722
+ args.push(...fields);
723
+ return createCommand(RequestType.HExpireTime, args);
724
+ }
725
+ /**
726
+ * @internal
727
+ */
728
+ function createHPExpireTime(key, fields) {
729
+ const args = [key];
730
+ // Add FIELDS keyword and field count - always required when fields parameter exists
731
+ args.push("FIELDS", fields.length.toString());
732
+ // Add field names
733
+ args.push(...fields);
734
+ return createCommand(RequestType.HPExpireTime, args);
735
+ }
552
736
  /**
553
737
  * @internal
554
738
  */
@@ -2239,6 +2423,44 @@ var ConditionalChange;
2239
2423
  */
2240
2424
  ConditionalChange["ONLY_IF_DOES_NOT_EXIST"] = "NX";
2241
2425
  })(ConditionalChange || (exports.ConditionalChange = ConditionalChange = {}));
2426
+ /**
2427
+ * Field conditional change options for hash field expiration commands.
2428
+ * Used with HSETEX command to control field setting behavior.
2429
+ */
2430
+ var HashFieldConditionalChange;
2431
+ (function (HashFieldConditionalChange) {
2432
+ /**
2433
+ * Only set fields if all of them already exist. Equivalent to `FXX` in the Valkey API.
2434
+ */
2435
+ HashFieldConditionalChange["ONLY_IF_ALL_EXIST"] = "FXX";
2436
+ /**
2437
+ * Only set fields if none of them already exist. Equivalent to `FNX` in the Valkey API.
2438
+ */
2439
+ HashFieldConditionalChange["ONLY_IF_NONE_EXIST"] = "FNX";
2440
+ })(HashFieldConditionalChange || (exports.HashFieldConditionalChange = HashFieldConditionalChange = {}));
2441
+ /**
2442
+ * Expiration condition options for hash field expiration commands.
2443
+ * Used with HEXPIRE, HPEXPIRE, HEXPIREAT, and HPEXPIREAT commands to control expiration setting behavior.
2444
+ */
2445
+ var HashExpirationCondition;
2446
+ (function (HashExpirationCondition) {
2447
+ /**
2448
+ * Only set expiration when field has no expiration. Equivalent to `NX` in the Valkey API.
2449
+ */
2450
+ HashExpirationCondition["ONLY_IF_NO_EXPIRY"] = "NX";
2451
+ /**
2452
+ * Only set expiration when field has existing expiration. Equivalent to `XX` in the Valkey API.
2453
+ */
2454
+ HashExpirationCondition["ONLY_IF_HAS_EXPIRY"] = "XX";
2455
+ /**
2456
+ * Only set expiration when new expiration is greater than current. Equivalent to `GT` in the Valkey API.
2457
+ */
2458
+ HashExpirationCondition["ONLY_IF_GREATER_THAN_CURRENT"] = "GT";
2459
+ /**
2460
+ * Only set expiration when new expiration is less than current. Equivalent to `LT` in the Valkey API.
2461
+ */
2462
+ HashExpirationCondition["ONLY_IF_LESS_THAN_CURRENT"] = "LT";
2463
+ })(HashExpirationCondition || (exports.HashExpirationCondition = HashExpirationCondition = {}));
2242
2464
  /**
2243
2465
  * @internal
2244
2466
  */
@@ -35,19 +35,19 @@ export declare namespace GlideClientConfiguration {
35
35
  /**
36
36
  * Configuration options for creating a {@link GlideClient | GlideClient}.
37
37
  *
38
- * Extends `BaseClientConfiguration` with properties specific to `GlideClient`, such as database selection,
38
+ * Extends `BaseClientConfiguration` with properties specific to `GlideClient`, such as
39
39
  * reconnection strategies, and Pub/Sub subscription settings.
40
40
  *
41
41
  * @remarks
42
42
  * This configuration allows you to tailor the client's behavior when connecting to a standalone Valkey Glide server.
43
43
  *
44
- * - **Database Selection**: Use `databaseId` to specify which logical database to connect to.
44
+ * - **Database Selection**: Use `databaseId` (inherited from BaseClientConfiguration) to specify which logical database to connect to.
45
45
  * - **Pub/Sub Subscriptions**: Predefine Pub/Sub channels and patterns to subscribe to upon connection establishment.
46
46
  *
47
47
  * @example
48
48
  * ```typescript
49
49
  * const config: GlideClientConfiguration = {
50
- * databaseId: 1,
50
+ * databaseId: 1, // Inherited from BaseClientConfiguration
51
51
  * pubsubSubscriptions: {
52
52
  * channelsAndPatterns: {
53
53
  * [GlideClientConfiguration.PubSubChannelModes.Pattern]: new Set(['news.*']),
@@ -60,10 +60,6 @@ export declare namespace GlideClientConfiguration {
60
60
  * ```
61
61
  */
62
62
  export type GlideClientConfiguration = BaseClientConfiguration & {
63
- /**
64
- * index of the logical database to connect to.
65
- */
66
- databaseId?: number;
67
63
  /**
68
64
  * PubSub subscriptions to be used for the client.
69
65
  * Will be applied via SUBSCRIBE/PSUBSCRIBE commands during connection establishment.
@@ -266,6 +262,21 @@ export declare class GlideClient extends BaseClient {
266
262
  /**
267
263
  * Changes the currently selected database.
268
264
  *
265
+ * **WARNING**: This command is NOT RECOMMENDED for production use.
266
+ * Upon reconnection, the client will revert to the database_id specified
267
+ * in the client configuration (default: 0), NOT the database selected
268
+ * via this command.
269
+ *
270
+ * **RECOMMENDED APPROACH**: Use the `databaseId` parameter in client
271
+ * configuration instead:
272
+ *
273
+ * ```typescript
274
+ * const client = await GlideClient.createClient({
275
+ * addresses: [{ host: "localhost", port: 6379 }],
276
+ * databaseId: 5 // Recommended: persists across reconnections
277
+ * });
278
+ * ```
279
+ *
269
280
  * @see {@link https://valkey.io/commands/select/|valkey.io} for details.
270
281
  *
271
282
  * @param index - The index of the database to select.
@@ -273,9 +284,10 @@ export declare class GlideClient extends BaseClient {
273
284
  *
274
285
  * @example
275
286
  * ```typescript
276
- * // Example usage of select method
287
+ * // Example usage of select method (NOT RECOMMENDED)
277
288
  * const result = await client.select(2);
278
289
  * console.log(result); // Output: 'OK'
290
+ * // Note: Database selection will be lost on reconnection!
279
291
  * ```
280
292
  */
281
293
  select(index: number): Promise<"OK">;
@@ -751,9 +763,7 @@ export declare class GlideClient extends BaseClient {
751
763
  *
752
764
  * @example
753
765
  * ```typescript
754
- * let response = await client.watch(["sampleKey"]);
755
- * console.log(response); // Output: "OK"
756
- * response = await client.unwatch();
766
+ * let response = await client.unwatch();
757
767
  * console.log(response); // Output: "OK"
758
768
  * ```
759
769
  */
@@ -36,7 +36,6 @@ class GlideClient extends _1.BaseClient {
36
36
  */
37
37
  createClientRequest(options) {
38
38
  const configuration = super.createClientRequest(options);
39
- configuration.databaseId = options.databaseId;
40
39
  this.configurePubsub(options, configuration);
41
40
  if (options.advancedConfiguration) {
42
41
  this.configureAdvancedConfigurationBase(options.advancedConfiguration, configuration);
@@ -229,6 +228,21 @@ class GlideClient extends _1.BaseClient {
229
228
  /**
230
229
  * Changes the currently selected database.
231
230
  *
231
+ * **WARNING**: This command is NOT RECOMMENDED for production use.
232
+ * Upon reconnection, the client will revert to the database_id specified
233
+ * in the client configuration (default: 0), NOT the database selected
234
+ * via this command.
235
+ *
236
+ * **RECOMMENDED APPROACH**: Use the `databaseId` parameter in client
237
+ * configuration instead:
238
+ *
239
+ * ```typescript
240
+ * const client = await GlideClient.createClient({
241
+ * addresses: [{ host: "localhost", port: 6379 }],
242
+ * databaseId: 5 // Recommended: persists across reconnections
243
+ * });
244
+ * ```
245
+ *
232
246
  * @see {@link https://valkey.io/commands/select/|valkey.io} for details.
233
247
  *
234
248
  * @param index - The index of the database to select.
@@ -236,9 +250,10 @@ class GlideClient extends _1.BaseClient {
236
250
  *
237
251
  * @example
238
252
  * ```typescript
239
- * // Example usage of select method
253
+ * // Example usage of select method (NOT RECOMMENDED)
240
254
  * const result = await client.select(2);
241
255
  * console.log(result); // Output: 'OK'
256
+ * // Note: Database selection will be lost on reconnection!
242
257
  * ```
243
258
  */
244
259
  async select(index) {
@@ -787,9 +802,7 @@ class GlideClient extends _1.BaseClient {
787
802
  *
788
803
  * @example
789
804
  * ```typescript
790
- * let response = await client.watch(["sampleKey"]);
791
- * console.log(response); // Output: "OK"
792
- * response = await client.unwatch();
805
+ * let response = await client.unwatch();
793
806
  * console.log(response); // Output: "OK"
794
807
  * ```
795
808
  */
@@ -91,6 +91,11 @@ export declare namespace GlideClusterClientConfiguration {
91
91
  * @example
92
92
  * ```typescript
93
93
  * const config: GlideClusterClientConfiguration = {
94
+ * addresses: [
95
+ * { host: 'cluster-node-1.example.com', port: 6379 },
96
+ * { host: 'cluster-node-2.example.com', port: 6379 },
97
+ * ],
98
+ * databaseId: 5, // Connect to database 5 (requires Valkey 9.0+ with multi-database cluster mode)
94
99
  * periodicChecks: {
95
100
  * duration_in_sec: 30, // Perform periodic checks every 30 seconds
96
101
  * },
@@ -391,12 +396,12 @@ export declare class GlideClusterClient extends BaseClient {
391
396
  /**
392
397
  * Creates a new `GlideClusterClient` instance and establishes connections to a Valkey Cluster.
393
398
  *
394
- * @param options - The configuration options for the client, including cluster addresses, authentication credentials, TLS settings, periodic checks, and Pub/Sub subscriptions.
399
+ * @param options - The configuration options for the client, including cluster addresses, database selection, authentication credentials, TLS settings, periodic checks, and Pub/Sub subscriptions.
395
400
  * @returns A promise that resolves to a connected `GlideClusterClient` instance.
396
401
  *
397
402
  * @remarks
398
403
  * Use this static method to create and connect a `GlideClusterClient` to a Valkey Cluster.
399
- * The client will automatically handle connection establishment, including cluster topology discovery and handling of authentication and TLS configurations.
404
+ * The client will automatically handle connection establishment, including cluster topology discovery, database selection, and handling of authentication and TLS configurations.
400
405
  *
401
406
  * @example
402
407
  * ```typescript
@@ -408,6 +413,7 @@ export declare class GlideClusterClient extends BaseClient {
408
413
  * { host: 'address1.example.com', port: 6379 },
409
414
  * { host: 'address2.example.com', port: 6379 },
410
415
  * ],
416
+ * databaseId: 5, // Connect to database 5 (requires Valkey 9.0+)
411
417
  * credentials: {
412
418
  * username: 'user1',
413
419
  * password: 'passwordA',
@@ -436,6 +442,7 @@ export declare class GlideClusterClient extends BaseClient {
436
442
  *
437
443
  * @remarks
438
444
  * - **Cluster Topology Discovery**: The client will automatically discover the cluster topology based on the seed addresses provided.
445
+ * - **Database Selection**: Use `databaseId` to specify which logical database to connect to. Requires Valkey 9.0+ with multi-database cluster mode enabled.
439
446
  * - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
440
447
  * - **TLS**: If `useTLS` is set to `true`, the client will establish secure connections using TLS.
441
448
  * Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail.
@@ -485,19 +492,21 @@ export declare class GlideClusterClient extends BaseClient {
485
492
  * await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "notMyKey", value: "value3"}, {key: "somethingElse", value: "value4"}]);
486
493
  * let cursor = new ClusterScanCursor();
487
494
  * const matchedKeys: GlideString[] = [];
495
+ * let keys: GlideString[] = [];
488
496
  * while (!cursor.isFinished()) {
489
- * const [cursor, keys] = await client.scan(cursor, { match: "*key*", count: 10 });
497
+ * [cursor, keys] = await client.scan(cursor, { match: "*key*", count: 10 });
490
498
  * matchedKeys.push(...keys);
491
499
  * }
492
- * console.log(matchedKeys); // ["key1", "key2", "notMyKey"]
500
+ * console.log(matchedKeys); // ["key1", "key2"]
493
501
  *
494
502
  * // Iterate over keys of a specific type
495
503
  * await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "key3", value: "value3"}]);
496
504
  * await client.sadd("thisIsASet", ["value4"]);
497
505
  * let cursor = new ClusterScanCursor();
498
506
  * const stringKeys: GlideString[] = [];
507
+ * let keys: GlideString[];
499
508
  * while (!cursor.isFinished()) {
500
- * const [cursor, keys] = await client.scan(cursor, { type: object.STRING });
509
+ * [cursor, keys] = await client.scan(cursor, { type: ObjectType.STRING });
501
510
  * stringKeys.push(...keys);
502
511
  * }
503
512
  * console.log(stringKeys); // ["key1", "key2", "key3"]
@@ -1296,9 +1305,7 @@ export declare class GlideClusterClient extends BaseClient {
1296
1305
  *
1297
1306
  * @example
1298
1307
  * ```typescript
1299
- * let response = await client.watch(["sampleKey"]);
1300
- * console.log(response); // Output: "OK"
1301
- * response = await client.unwatch();
1308
+ * let response = await client.unwatch();
1302
1309
  * console.log(response); // Output: "OK"
1303
1310
  * ```
1304
1311
  */
@@ -84,12 +84,12 @@ class GlideClusterClient extends _1.BaseClient {
84
84
  /**
85
85
  * Creates a new `GlideClusterClient` instance and establishes connections to a Valkey Cluster.
86
86
  *
87
- * @param options - The configuration options for the client, including cluster addresses, authentication credentials, TLS settings, periodic checks, and Pub/Sub subscriptions.
87
+ * @param options - The configuration options for the client, including cluster addresses, database selection, authentication credentials, TLS settings, periodic checks, and Pub/Sub subscriptions.
88
88
  * @returns A promise that resolves to a connected `GlideClusterClient` instance.
89
89
  *
90
90
  * @remarks
91
91
  * Use this static method to create and connect a `GlideClusterClient` to a Valkey Cluster.
92
- * The client will automatically handle connection establishment, including cluster topology discovery and handling of authentication and TLS configurations.
92
+ * The client will automatically handle connection establishment, including cluster topology discovery, database selection, and handling of authentication and TLS configurations.
93
93
  *
94
94
  * @example
95
95
  * ```typescript
@@ -101,6 +101,7 @@ class GlideClusterClient extends _1.BaseClient {
101
101
  * { host: 'address1.example.com', port: 6379 },
102
102
  * { host: 'address2.example.com', port: 6379 },
103
103
  * ],
104
+ * databaseId: 5, // Connect to database 5 (requires Valkey 9.0+)
104
105
  * credentials: {
105
106
  * username: 'user1',
106
107
  * password: 'passwordA',
@@ -129,6 +130,7 @@ class GlideClusterClient extends _1.BaseClient {
129
130
  *
130
131
  * @remarks
131
132
  * - **Cluster Topology Discovery**: The client will automatically discover the cluster topology based on the seed addresses provided.
133
+ * - **Database Selection**: Use `databaseId` to specify which logical database to connect to. Requires Valkey 9.0+ with multi-database cluster mode enabled.
132
134
  * - **Authentication**: If `credentials` are provided, the client will attempt to authenticate using the specified username and password.
133
135
  * - **TLS**: If `useTLS` is set to `true`, the client will establish secure connections using TLS.
134
136
  * Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail.
@@ -241,19 +243,21 @@ class GlideClusterClient extends _1.BaseClient {
241
243
  * await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "notMyKey", value: "value3"}, {key: "somethingElse", value: "value4"}]);
242
244
  * let cursor = new ClusterScanCursor();
243
245
  * const matchedKeys: GlideString[] = [];
246
+ * let keys: GlideString[] = [];
244
247
  * while (!cursor.isFinished()) {
245
- * const [cursor, keys] = await client.scan(cursor, { match: "*key*", count: 10 });
248
+ * [cursor, keys] = await client.scan(cursor, { match: "*key*", count: 10 });
246
249
  * matchedKeys.push(...keys);
247
250
  * }
248
- * console.log(matchedKeys); // ["key1", "key2", "notMyKey"]
251
+ * console.log(matchedKeys); // ["key1", "key2"]
249
252
  *
250
253
  * // Iterate over keys of a specific type
251
254
  * await client.mset([{key: "key1", value: "value1"}, {key: "key2", value: "value2"}, {key: "key3", value: "value3"}]);
252
255
  * await client.sadd("thisIsASet", ["value4"]);
253
256
  * let cursor = new ClusterScanCursor();
254
257
  * const stringKeys: GlideString[] = [];
258
+ * let keys: GlideString[];
255
259
  * while (!cursor.isFinished()) {
256
- * const [cursor, keys] = await client.scan(cursor, { type: object.STRING });
260
+ * [cursor, keys] = await client.scan(cursor, { type: ObjectType.STRING });
257
261
  * stringKeys.push(...keys);
258
262
  * }
259
263
  * console.log(stringKeys); // ["key1", "key2", "key3"]
@@ -1130,9 +1134,7 @@ class GlideClusterClient extends _1.BaseClient {
1130
1134
  *
1131
1135
  * @example
1132
1136
  * ```typescript
1133
- * let response = await client.watch(["sampleKey"]);
1134
- * console.log(response); // Output: "OK"
1135
- * response = await client.unwatch();
1137
+ * let response = await client.unwatch();
1136
1138
  * console.log(response); // Output: "OK"
1137
1139
  * ```
1138
1140
  */
@@ -455,6 +455,17 @@ export namespace command_request {
455
455
  HSetNX = 614,
456
456
  HStrlen = 615,
457
457
  HVals = 616,
458
+ HSetEx = 617,
459
+ HGetEx = 618,
460
+ HExpire = 619,
461
+ HExpireAt = 620,
462
+ HPExpire = 621,
463
+ HPExpireAt = 622,
464
+ HPersist = 623,
465
+ HTtl = 624,
466
+ HPTtl = 625,
467
+ HExpireTime = 626,
468
+ HPExpireTime = 627,
458
469
  PfAdd = 701,
459
470
  PfCount = 702,
460
471
  PfMerge = 703,
@@ -838,6 +838,17 @@ $root.command_request = (function() {
838
838
  * @property {number} HSetNX=614 HSetNX value
839
839
  * @property {number} HStrlen=615 HStrlen value
840
840
  * @property {number} HVals=616 HVals value
841
+ * @property {number} HSetEx=617 HSetEx value
842
+ * @property {number} HGetEx=618 HGetEx value
843
+ * @property {number} HExpire=619 HExpire value
844
+ * @property {number} HExpireAt=620 HExpireAt value
845
+ * @property {number} HPExpire=621 HPExpire value
846
+ * @property {number} HPExpireAt=622 HPExpireAt value
847
+ * @property {number} HPersist=623 HPersist value
848
+ * @property {number} HTtl=624 HTtl value
849
+ * @property {number} HPTtl=625 HPTtl value
850
+ * @property {number} HExpireTime=626 HExpireTime value
851
+ * @property {number} HPExpireTime=627 HPExpireTime value
841
852
  * @property {number} PfAdd=701 PfAdd value
842
853
  * @property {number} PfCount=702 PfCount value
843
854
  * @property {number} PfMerge=703 PfMerge value
@@ -1218,6 +1229,17 @@ $root.command_request = (function() {
1218
1229
  values[valuesById[614] = "HSetNX"] = 614;
1219
1230
  values[valuesById[615] = "HStrlen"] = 615;
1220
1231
  values[valuesById[616] = "HVals"] = 616;
1232
+ values[valuesById[617] = "HSetEx"] = 617;
1233
+ values[valuesById[618] = "HGetEx"] = 618;
1234
+ values[valuesById[619] = "HExpire"] = 619;
1235
+ values[valuesById[620] = "HExpireAt"] = 620;
1236
+ values[valuesById[621] = "HPExpire"] = 621;
1237
+ values[valuesById[622] = "HPExpireAt"] = 622;
1238
+ values[valuesById[623] = "HPersist"] = 623;
1239
+ values[valuesById[624] = "HTtl"] = 624;
1240
+ values[valuesById[625] = "HPTtl"] = 625;
1241
+ values[valuesById[626] = "HExpireTime"] = 626;
1242
+ values[valuesById[627] = "HPExpireTime"] = 627;
1221
1243
  values[valuesById[701] = "PfAdd"] = 701;
1222
1244
  values[valuesById[702] = "PfCount"] = 702;
1223
1245
  values[valuesById[703] = "PfMerge"] = 703;