@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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { AdvancedBaseClientConfiguration, BaseClient, BaseClientConfiguration, DecoderOption, GlideReturnType, GlideString, PubSubMsg, NodeDiscoveryMode } from "./BaseClient";
5
5
  import { Batch } from "./Batch";
6
- import { BatchOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsFullResponse, InfoOptions, LolwutOptions, ScanOptions } from "./Commands";
6
+ import { BatchOptions, ClientPauseMode, ClientTrackingInfo, FailoverOptions, FlushMode, FunctionListOptions, FunctionListResponse, FunctionRestorePolicy, FunctionStatsFullResponse, InfoOptions, LatencyEntry, LatencyEventInfo, LolwutOptions, MigrateOptions, MemoryStats, ScanOptions } from "./Commands";
7
7
  export declare namespace GlideClientConfiguration {
8
8
  /**
9
9
  * Enum representing pubsub subscription modes.
@@ -378,6 +378,23 @@ export declare class GlideClient extends BaseClient {
378
378
  * ```
379
379
  */
380
380
  clientId(): Promise<number>;
381
+ /**
382
+ * Returns information about the current client connection's use
383
+ * of the server assisted client side caching feature.
384
+ *
385
+ * @see {@link https://valkey.io/commands/client-trackinginfo/|valkey.io} for details.
386
+ *
387
+ * @returns The tracking info for the client.
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const info = await client.clientTrackingInfo();
392
+ * console.log(info.flags); // Set { "off" }
393
+ * console.log(info.redirect); // -1
394
+ * console.log(info.prefixes); // Set {}
395
+ * ```
396
+ */
397
+ clientTrackingInfo(): Promise<ClientTrackingInfo>;
381
398
  /**
382
399
  * Reads the configuration parameters of the running server.
383
400
  * Starting from server version 7, command supports multiple parameters.
@@ -713,6 +730,127 @@ export declare class GlideClient extends BaseClient {
713
730
  * ```
714
731
  */
715
732
  lastsave(): Promise<number>;
733
+ /**
734
+ * Returns the latency spike time series for the specified event.
735
+ *
736
+ * @see {@link https://valkey.io/commands/latency-history/|valkey.io} for details.
737
+ *
738
+ * @param event - The name of the latency event (e.g., `"command"`).
739
+ * @returns An array of {@link LatencyEntry} for the event, or an empty array if the event doesn't exist.
740
+ *
741
+ * @example
742
+ * ```typescript
743
+ * const history = await client.latencyHistory("command");
744
+ * for (const entry of history) {
745
+ * console.log(`Time: ${entry.time}, Latency: ${entry.latency}`);
746
+ * }
747
+ * ```
748
+ */
749
+ latencyHistory(event: GlideString): Promise<LatencyEntry[]>;
750
+ /**
751
+ * Reports the latest latency events logged by the server.
752
+ *
753
+ * @see {@link https://valkey.io/commands/latency-latest/|valkey.io} for details.
754
+ *
755
+ * @returns An array of {@link LatencyEventInfo} for the latest latency events.
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * const latest = await client.latencyLatest();
760
+ * for (const info of latest) {
761
+ * console.log(`Event: ${info.eventName}, Latest: ${info.latestDuration}`);
762
+ * }
763
+ * ```
764
+ */
765
+ latencyLatest(): Promise<LatencyEventInfo[]>;
766
+ /**
767
+ * Resets the latency spike time series for all or specified events.
768
+ * If no events are provided, resets the latency spike time series for all events.
769
+ *
770
+ * @see {@link https://valkey.io/commands/latency-reset/|valkey.io} for details.
771
+ *
772
+ * @param events - The event names to reset. If not provided, resets all events.
773
+ * @returns The number of event time series that were reset.
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * await client.latencyReset(); // Resets all events
778
+ * await client.latencyReset(["command"]); // Resets only "command"
779
+ * ```
780
+ */
781
+ latencyReset(events?: GlideString[]): Promise<number>;
782
+ /**
783
+ * Synchronously saves the dataset to disk.
784
+ *
785
+ * @see {@link https://valkey.io/commands/save/|valkey.io} for more details.
786
+ *
787
+ * @returns `"OK"`
788
+ *
789
+ * @example
790
+ * ```typescript
791
+ * const result = await client.save();
792
+ * console.log(result); // "OK"
793
+ * ```
794
+ */
795
+ save(): Promise<"OK">;
796
+ /**
797
+ * Asynchronously saves the dataset to disk in the background.
798
+ *
799
+ * @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
800
+ *
801
+ * @returns A non-empty status string.
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * const result = await client.bgsave();
806
+ * console.log(result); // "Background saving started"
807
+ * ```
808
+ */
809
+ bgsave(): Promise<string>;
810
+ /**
811
+ * Schedules a background save of the database.
812
+ *
813
+ * @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
814
+ *
815
+ * @returns A non-empty status string.
816
+ *
817
+ * @example
818
+ * ```typescript
819
+ * const result = await client.bgsaveSchedule();
820
+ * console.log(result); // "Background saving scheduled"
821
+ * ```
822
+ */
823
+ bgsaveSchedule(): Promise<string>;
824
+ /**
825
+ * Aborts all in-progress and scheduled background saves.
826
+ *
827
+ * @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
828
+ *
829
+ * @since Valkey 8.1
830
+ *
831
+ * @returns A non-empty status string.
832
+ *
833
+ * @example
834
+ * ```typescript
835
+ * const result = await client.bgsaveCancel();
836
+ * console.log(result); // "Background saving cancelled"
837
+ * ```
838
+ */
839
+ bgsaveCancel(): Promise<string>;
840
+ /**
841
+ * Initiates a background rewrite of the append-only file (AOF).
842
+ *
843
+ * @see {@link https://valkey.io/commands/bgrewriteaof/|valkey.io} for more details.
844
+ *
845
+ * @returns A non-empty status string.
846
+ *
847
+ * @example
848
+ * ```typescript
849
+ * const result = await client.bgrewriteaof();
850
+ * console.log(result); // "Background append only file rewriting started"
851
+ * ```
852
+ */
853
+ bgrewriteaof(): Promise<string>;
716
854
  /**
717
855
  * Returns a random existing key name from the currently selected database.
718
856
  *
@@ -727,6 +865,38 @@ export declare class GlideClient extends BaseClient {
727
865
  * ```
728
866
  */
729
867
  randomKey(options?: DecoderOption): Promise<GlideString | null>;
868
+ /**
869
+ * Atomically transfers a key or multiple keys from the current Valkey instance
870
+ * to a destination Valkey instance.
871
+ * On success, keys are deleted from the source unless `copy` is set to `true` in options.
872
+ *
873
+ * @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
874
+ *
875
+ * @param host - The host of the destination Valkey instance.
876
+ * @param port - The port of the destination Valkey instance.
877
+ * @param key - The key to migrate, or an array of keys to migrate.
878
+ * @param destinationDB - The database index on the destination instance.
879
+ * @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
880
+ * @param options - Optional migration options.
881
+ * @returns `"OK"` on success, `"NOKEY"` if the key(s) do not exist.
882
+ *
883
+ * @example Single-key:
884
+ * ```typescript
885
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000);
886
+ * console.log(result); // "OK"
887
+ * ```
888
+ * @example Single-key with copy and replace:
889
+ * ```typescript
890
+ * const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000, { copy: true, replace: true });
891
+ * console.log(result); // "OK"
892
+ * ```
893
+ * @example Multi-key:
894
+ * ```typescript
895
+ * const result = await client.migrate("127.0.0.1", 6379, ["key1", "key2"], 0, 5000);
896
+ * console.log(result); // "OK"
897
+ * ```
898
+ */
899
+ migrate(host: string, port: number, key: GlideString | GlideString[], destinationDB: number, timeout: number, options?: MigrateOptions): Promise<string>;
730
900
  /**
731
901
  * Flushes all the previously watched keys for a transaction. Executing a transaction will
732
902
  * automatically flush all previously watched keys.
@@ -844,4 +1014,146 @@ export declare class GlideClient extends BaseClient {
844
1014
  * ```
845
1015
  */
846
1016
  getSubscriptions(): Promise<StandalonePubSubState>;
1017
+ /**
1018
+ * Suspends all clients for the specified timeout.
1019
+ *
1020
+ * @see {@link https://valkey.io/commands/client-pause/|valkey.io} for details.
1021
+ *
1022
+ * @param timeout - The time in milliseconds to pause clients.
1023
+ * @param mode - (Optional) The pause mode to use.
1024
+ * + If not provided, all commands are paused.
1025
+ * @param options - (Optional) See {@link DecoderOption}.
1026
+ * @returns `"OK"` response on success.
1027
+ *
1028
+ * @example
1029
+ * ```typescript
1030
+ * const result = await client.clientPause(1000);
1031
+ * console.log(result); // Output: 'OK'
1032
+ * ```
1033
+ *
1034
+ * @example
1035
+ * ```typescript
1036
+ * const result = await client.clientPause(1000, ClientPauseMode.WRITE);
1037
+ * console.log(result); // Output: 'OK'
1038
+ * ```
1039
+ */
1040
+ clientPause(timeout: number, mode?: ClientPauseMode, options?: DecoderOption): Promise<"OK">;
1041
+ /**
1042
+ * Resumes processing commands on all clients.
1043
+ *
1044
+ * @see {@link https://valkey.io/commands/client-unpause/|valkey.io} for details.
1045
+ *
1046
+ * @param options - (Optional) See {@link DecoderOption}.
1047
+ * @returns `"OK"` response on success.
1048
+ *
1049
+ * @example
1050
+ * ```typescript
1051
+ * const result = await client.clientUnpause();
1052
+ * console.log(result); // Output: 'OK'
1053
+ * ```
1054
+ */
1055
+ clientUnpause(options?: DecoderOption): Promise<"OK">;
1056
+ /**
1057
+ * Starts a coordinated failover from the connected primary to one of its replicas.
1058
+ * This is the standalone equivalent of `CLUSTER FAILOVER`.
1059
+ *
1060
+ * @see {@link https://valkey.io/commands/failover/|valkey.io} for details.
1061
+ *
1062
+ * @param options - (Optional) Failover options. See {@link FailoverOptions}.
1063
+ * @returns `"OK"` if the failover was successfully initiated.
1064
+ *
1065
+ * @example
1066
+ * ```typescript
1067
+ * const result = await client.failover();
1068
+ * console.log(result); // Output: 'OK'
1069
+ * ```
1070
+ */
1071
+ failover(options?: FailoverOptions): Promise<"OK">;
1072
+ /**
1073
+ * Makes the server a replica of the specified primary.
1074
+ *
1075
+ * @see {@link https://valkey.io/commands/replicaof/|valkey.io} for details.
1076
+ *
1077
+ * @param host - The host of the primary to replicate.
1078
+ * @param port - The port of the primary to replicate.
1079
+ * @returns `"OK"` on success.
1080
+ *
1081
+ * @example
1082
+ * ```typescript
1083
+ * const result = await client.replicaof("localhost", 6379);
1084
+ * console.log(result); // Output: 'OK'
1085
+ * ```
1086
+ */
1087
+ replicaof(host: string, port: number): Promise<"OK">;
1088
+ /**
1089
+ * Promotes the current server to a primary by stopping replication.
1090
+ *
1091
+ * @see {@link https://valkey.io/commands/replicaof/|valkey.io} for details.
1092
+ *
1093
+ * @returns `"OK"` on success.
1094
+ *
1095
+ * @example
1096
+ * ```typescript
1097
+ * const result = await client.replicaofNoOne();
1098
+ * console.log(result); // Output: 'OK'
1099
+ * ```
1100
+ */
1101
+ replicaofNoOne(): Promise<"OK">;
1102
+ /**
1103
+ * Returns a report about memory problems detected by the server.
1104
+ *
1105
+ * @see {@link https://valkey.io/commands/memory-doctor/|valkey.io} for details.
1106
+ *
1107
+ * @returns The memory diagnostic report.
1108
+ *
1109
+ * @example
1110
+ * ```typescript
1111
+ * const report = await client.memoryDoctor();
1112
+ * console.log(report); // Output: "Sam, I have no memory problems"
1113
+ * ```
1114
+ */
1115
+ memoryDoctor(): Promise<string>;
1116
+ /**
1117
+ * Returns the internal statistics of the memory allocator.
1118
+ *
1119
+ * @see {@link https://valkey.io/commands/memory-malloc-stats/|valkey.io} for details.
1120
+ *
1121
+ * @returns The memory allocator statistics.
1122
+ *
1123
+ * @example
1124
+ * ```typescript
1125
+ * const stats = await client.memoryMallocStats();
1126
+ * console.log(stats);
1127
+ * ```
1128
+ */
1129
+ memoryMallocStats(): Promise<string>;
1130
+ /**
1131
+ * Asks the server to reclaim memory from the allocator back to the operating system.
1132
+ *
1133
+ * @see {@link https://valkey.io/commands/memory-purge/|valkey.io} for details.
1134
+ *
1135
+ * @returns `"OK"`.
1136
+ *
1137
+ * @example
1138
+ * ```typescript
1139
+ * const result = await client.memoryPurge();
1140
+ * console.log(result); // Output: 'OK'
1141
+ * ```
1142
+ */
1143
+ memoryPurge(): Promise<"OK">;
1144
+ /**
1145
+ * Returns detailed memory consumption statistics of the server.
1146
+ *
1147
+ * @see {@link https://valkey.io/commands/memory-stats/|valkey.io} for details.
1148
+ *
1149
+ * @returns A {@link MemoryStats} object containing detailed memory usage statistics.
1150
+ *
1151
+ * @example
1152
+ * ```typescript
1153
+ * const stats = await client.memoryStats();
1154
+ * console.log(stats.peakAllocated); // Peak memory in bytes
1155
+ * console.log(stats.totalAllocated); // Total allocated memory in bytes
1156
+ * ```
1157
+ */
1158
+ memoryStats(): Promise<MemoryStats>;
847
1159
  }