@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.
- package/build-ts/BaseClient.d.ts +101 -1
- package/build-ts/BaseClient.js +108 -2
- package/build-ts/Batch.d.ts +43 -1
- package/build-ts/Batch.js +48 -0
- package/build-ts/ClientSideCache.d.ts +16 -0
- package/build-ts/ClientSideCache.js +6 -0
- package/build-ts/Commands.d.ts +179 -0
- package/build-ts/Commands.js +311 -1
- package/build-ts/Errors.d.ts +2 -0
- package/build-ts/Errors.js +4 -1
- package/build-ts/GlideClient.d.ts +313 -1
- package/build-ts/GlideClient.js +373 -0
- package/build-ts/GlideClusterClient.d.ts +278 -1
- package/build-ts/GlideClusterClient.js +380 -6
- package/build-ts/GlideMonitorClient.d.ts +36 -0
- package/build-ts/GlideMonitorClient.js +103 -0
- package/build-ts/ProtobufMessage.d.ts +113 -1
- package/build-ts/ProtobufMessage.js +261 -0
- package/build-ts/index.d.ts +1 -0
- package/build-ts/index.js +1 -0
- package/build-ts/native.d.ts +12 -0
- package/build-ts/native.js +5 -1
- package/package.json +20 -11
package/build-ts/GlideClient.js
CHANGED
|
@@ -306,6 +306,25 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
306
306
|
async clientId() {
|
|
307
307
|
return this.createWritePromise((0, Commands_1.createClientId)());
|
|
308
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Returns information about the current client connection's use
|
|
311
|
+
* of the server assisted client side caching feature.
|
|
312
|
+
*
|
|
313
|
+
* @see {@link https://valkey.io/commands/client-trackinginfo/|valkey.io} for details.
|
|
314
|
+
*
|
|
315
|
+
* @returns The tracking info for the client.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const info = await client.clientTrackingInfo();
|
|
320
|
+
* console.log(info.flags); // Set { "off" }
|
|
321
|
+
* console.log(info.redirect); // -1
|
|
322
|
+
* console.log(info.prefixes); // Set {}
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
async clientTrackingInfo() {
|
|
326
|
+
return this.createWritePromise((0, Commands_1.createClientTrackingInfo)()).then((res) => (0, Commands_1.parseClientTrackingInfoResponse)((0, BaseClient_1.convertGlideRecordToRecord)(res)));
|
|
327
|
+
}
|
|
309
328
|
/**
|
|
310
329
|
* Reads the configuration parameters of the running server.
|
|
311
330
|
* Starting from server version 7, command supports multiple parameters.
|
|
@@ -695,6 +714,153 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
695
714
|
async lastsave() {
|
|
696
715
|
return this.createWritePromise((0, Commands_1.createLastSave)());
|
|
697
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Returns the latency spike time series for the specified event.
|
|
719
|
+
*
|
|
720
|
+
* @see {@link https://valkey.io/commands/latency-history/|valkey.io} for details.
|
|
721
|
+
*
|
|
722
|
+
* @param event - The name of the latency event (e.g., `"command"`).
|
|
723
|
+
* @returns An array of {@link LatencyEntry} for the event, or an empty array if the event doesn't exist.
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* const history = await client.latencyHistory("command");
|
|
728
|
+
* for (const entry of history) {
|
|
729
|
+
* console.log(`Time: ${entry.time}, Latency: ${entry.latency}`);
|
|
730
|
+
* }
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
733
|
+
async latencyHistory(event) {
|
|
734
|
+
return this.createWritePromise((0, Commands_1.createLatencyHistory)(event)).then((res) => (0, Commands_1.parseLatencyHistoryResponse)(res));
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Reports the latest latency events logged by the server.
|
|
738
|
+
*
|
|
739
|
+
* @see {@link https://valkey.io/commands/latency-latest/|valkey.io} for details.
|
|
740
|
+
*
|
|
741
|
+
* @returns An array of {@link LatencyEventInfo} for the latest latency events.
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* ```typescript
|
|
745
|
+
* const latest = await client.latencyLatest();
|
|
746
|
+
* for (const info of latest) {
|
|
747
|
+
* console.log(`Event: ${info.eventName}, Latest: ${info.latestDuration}`);
|
|
748
|
+
* }
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
751
|
+
async latencyLatest() {
|
|
752
|
+
return this.createWritePromise((0, Commands_1.createLatencyLatest)()).then((res) => (0, Commands_1.parseLatencyLatestResponse)(res));
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Resets the latency spike time series for all or specified events.
|
|
756
|
+
* If no events are provided, resets the latency spike time series for all events.
|
|
757
|
+
*
|
|
758
|
+
* @see {@link https://valkey.io/commands/latency-reset/|valkey.io} for details.
|
|
759
|
+
*
|
|
760
|
+
* @param events - The event names to reset. If not provided, resets all events.
|
|
761
|
+
* @returns The number of event time series that were reset.
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* ```typescript
|
|
765
|
+
* await client.latencyReset(); // Resets all events
|
|
766
|
+
* await client.latencyReset(["command"]); // Resets only "command"
|
|
767
|
+
* ```
|
|
768
|
+
*/
|
|
769
|
+
async latencyReset(events) {
|
|
770
|
+
return this.createWritePromise((0, Commands_1.createLatencyReset)(events));
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Synchronously saves the dataset to disk.
|
|
774
|
+
*
|
|
775
|
+
* @see {@link https://valkey.io/commands/save/|valkey.io} for more details.
|
|
776
|
+
*
|
|
777
|
+
* @returns `"OK"`
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* ```typescript
|
|
781
|
+
* const result = await client.save();
|
|
782
|
+
* console.log(result); // "OK"
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
785
|
+
async save() {
|
|
786
|
+
return this.createWritePromise((0, Commands_1.createSave)(), {
|
|
787
|
+
decoder: BaseClient_1.Decoder.String,
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Asynchronously saves the dataset to disk in the background.
|
|
792
|
+
*
|
|
793
|
+
* @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
|
|
794
|
+
*
|
|
795
|
+
* @returns A non-empty status string.
|
|
796
|
+
*
|
|
797
|
+
* @example
|
|
798
|
+
* ```typescript
|
|
799
|
+
* const result = await client.bgsave();
|
|
800
|
+
* console.log(result); // "Background saving started"
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
async bgsave() {
|
|
804
|
+
return this.createWritePromise((0, Commands_1.createBgSave)(), {
|
|
805
|
+
decoder: BaseClient_1.Decoder.String,
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Schedules a background save of the database.
|
|
810
|
+
*
|
|
811
|
+
* @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
|
|
812
|
+
*
|
|
813
|
+
* @returns A non-empty status string.
|
|
814
|
+
*
|
|
815
|
+
* @example
|
|
816
|
+
* ```typescript
|
|
817
|
+
* const result = await client.bgsaveSchedule();
|
|
818
|
+
* console.log(result); // "Background saving scheduled"
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
async bgsaveSchedule() {
|
|
822
|
+
return this.createWritePromise((0, Commands_1.createBgSave)(["SCHEDULE"]), {
|
|
823
|
+
decoder: BaseClient_1.Decoder.String,
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Aborts all in-progress and scheduled background saves.
|
|
828
|
+
*
|
|
829
|
+
* @see {@link https://valkey.io/commands/bgsave/|valkey.io} for more details.
|
|
830
|
+
*
|
|
831
|
+
* @since Valkey 8.1
|
|
832
|
+
*
|
|
833
|
+
* @returns A non-empty status string.
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* ```typescript
|
|
837
|
+
* const result = await client.bgsaveCancel();
|
|
838
|
+
* console.log(result); // "Background saving cancelled"
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
async bgsaveCancel() {
|
|
842
|
+
return this.createWritePromise((0, Commands_1.createBgSave)(["CANCEL"]), {
|
|
843
|
+
decoder: BaseClient_1.Decoder.String,
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Initiates a background rewrite of the append-only file (AOF).
|
|
848
|
+
*
|
|
849
|
+
* @see {@link https://valkey.io/commands/bgrewriteaof/|valkey.io} for more details.
|
|
850
|
+
*
|
|
851
|
+
* @returns A non-empty status string.
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```typescript
|
|
855
|
+
* const result = await client.bgrewriteaof();
|
|
856
|
+
* console.log(result); // "Background append only file rewriting started"
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
859
|
+
async bgrewriteaof() {
|
|
860
|
+
return this.createWritePromise((0, Commands_1.createBgRewriteAof)(), {
|
|
861
|
+
decoder: BaseClient_1.Decoder.String,
|
|
862
|
+
});
|
|
863
|
+
}
|
|
698
864
|
/**
|
|
699
865
|
* Returns a random existing key name from the currently selected database.
|
|
700
866
|
*
|
|
@@ -711,6 +877,40 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
711
877
|
async randomKey(options) {
|
|
712
878
|
return this.createWritePromise((0, Commands_1.createRandomKey)(), options);
|
|
713
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Atomically transfers a key or multiple keys from the current Valkey instance
|
|
882
|
+
* to a destination Valkey instance.
|
|
883
|
+
* On success, keys are deleted from the source unless `copy` is set to `true` in options.
|
|
884
|
+
*
|
|
885
|
+
* @see {@link https://valkey.io/commands/migrate/|valkey.io} for details.
|
|
886
|
+
*
|
|
887
|
+
* @param host - The host of the destination Valkey instance.
|
|
888
|
+
* @param port - The port of the destination Valkey instance.
|
|
889
|
+
* @param key - The key to migrate, or an array of keys to migrate.
|
|
890
|
+
* @param destinationDB - The database index on the destination instance.
|
|
891
|
+
* @param timeout - The maximum idle time in milliseconds for the bulk-transfer.
|
|
892
|
+
* @param options - Optional migration options.
|
|
893
|
+
* @returns `"OK"` on success, `"NOKEY"` if the key(s) do not exist.
|
|
894
|
+
*
|
|
895
|
+
* @example Single-key:
|
|
896
|
+
* ```typescript
|
|
897
|
+
* const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000);
|
|
898
|
+
* console.log(result); // "OK"
|
|
899
|
+
* ```
|
|
900
|
+
* @example Single-key with copy and replace:
|
|
901
|
+
* ```typescript
|
|
902
|
+
* const result = await client.migrate("127.0.0.1", 6379, "mykey", 0, 5000, { copy: true, replace: true });
|
|
903
|
+
* console.log(result); // "OK"
|
|
904
|
+
* ```
|
|
905
|
+
* @example Multi-key:
|
|
906
|
+
* ```typescript
|
|
907
|
+
* const result = await client.migrate("127.0.0.1", 6379, ["key1", "key2"], 0, 5000);
|
|
908
|
+
* console.log(result); // "OK"
|
|
909
|
+
* ```
|
|
910
|
+
*/
|
|
911
|
+
async migrate(host, port, key, destinationDB, timeout, options) {
|
|
912
|
+
return this.createWritePromise((0, Commands_1.createMigrate)(host, port, key, destinationDB, timeout, options));
|
|
913
|
+
}
|
|
714
914
|
/**
|
|
715
915
|
* Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
716
916
|
* automatically flush all previously watched keys.
|
|
@@ -847,5 +1047,178 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
847
1047
|
const response = await this.createWritePromise((0, Commands_1.createGetSubscriptions)());
|
|
848
1048
|
return this.parseGetSubscriptionsResponse(response);
|
|
849
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Suspends all clients for the specified timeout.
|
|
1052
|
+
*
|
|
1053
|
+
* @see {@link https://valkey.io/commands/client-pause/|valkey.io} for details.
|
|
1054
|
+
*
|
|
1055
|
+
* @param timeout - The time in milliseconds to pause clients.
|
|
1056
|
+
* @param mode - (Optional) The pause mode to use.
|
|
1057
|
+
* + If not provided, all commands are paused.
|
|
1058
|
+
* @param options - (Optional) See {@link DecoderOption}.
|
|
1059
|
+
* @returns `"OK"` response on success.
|
|
1060
|
+
*
|
|
1061
|
+
* @example
|
|
1062
|
+
* ```typescript
|
|
1063
|
+
* const result = await client.clientPause(1000);
|
|
1064
|
+
* console.log(result); // Output: 'OK'
|
|
1065
|
+
* ```
|
|
1066
|
+
*
|
|
1067
|
+
* @example
|
|
1068
|
+
* ```typescript
|
|
1069
|
+
* const result = await client.clientPause(1000, ClientPauseMode.WRITE);
|
|
1070
|
+
* console.log(result); // Output: 'OK'
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
async clientPause(timeout, mode, options) {
|
|
1074
|
+
return this.createWritePromise((0, Commands_1.createClientPause)(timeout, mode), options);
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Resumes processing commands on all clients.
|
|
1078
|
+
*
|
|
1079
|
+
* @see {@link https://valkey.io/commands/client-unpause/|valkey.io} for details.
|
|
1080
|
+
*
|
|
1081
|
+
* @param options - (Optional) See {@link DecoderOption}.
|
|
1082
|
+
* @returns `"OK"` response on success.
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* ```typescript
|
|
1086
|
+
* const result = await client.clientUnpause();
|
|
1087
|
+
* console.log(result); // Output: 'OK'
|
|
1088
|
+
* ```
|
|
1089
|
+
*/
|
|
1090
|
+
async clientUnpause(options) {
|
|
1091
|
+
return this.createWritePromise((0, Commands_1.createClientUnpause)(), options);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Starts a coordinated failover from the connected primary to one of its replicas.
|
|
1095
|
+
* This is the standalone equivalent of `CLUSTER FAILOVER`.
|
|
1096
|
+
*
|
|
1097
|
+
* @see {@link https://valkey.io/commands/failover/|valkey.io} for details.
|
|
1098
|
+
*
|
|
1099
|
+
* @param options - (Optional) Failover options. See {@link FailoverOptions}.
|
|
1100
|
+
* @returns `"OK"` if the failover was successfully initiated.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const result = await client.failover();
|
|
1105
|
+
* console.log(result); // Output: 'OK'
|
|
1106
|
+
* ```
|
|
1107
|
+
*/
|
|
1108
|
+
async failover(options) {
|
|
1109
|
+
return this.createWritePromise((0, Commands_1.createFailover)(options), {
|
|
1110
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Makes the server a replica of the specified primary.
|
|
1115
|
+
*
|
|
1116
|
+
* @see {@link https://valkey.io/commands/replicaof/|valkey.io} for details.
|
|
1117
|
+
*
|
|
1118
|
+
* @param host - The host of the primary to replicate.
|
|
1119
|
+
* @param port - The port of the primary to replicate.
|
|
1120
|
+
* @returns `"OK"` on success.
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* const result = await client.replicaof("localhost", 6379);
|
|
1125
|
+
* console.log(result); // Output: 'OK'
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
async replicaof(host, port) {
|
|
1129
|
+
return this.createWritePromise((0, Commands_1.createReplicaOf)(host, port), {
|
|
1130
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Promotes the current server to a primary by stopping replication.
|
|
1135
|
+
*
|
|
1136
|
+
* @see {@link https://valkey.io/commands/replicaof/|valkey.io} for details.
|
|
1137
|
+
*
|
|
1138
|
+
* @returns `"OK"` on success.
|
|
1139
|
+
*
|
|
1140
|
+
* @example
|
|
1141
|
+
* ```typescript
|
|
1142
|
+
* const result = await client.replicaofNoOne();
|
|
1143
|
+
* console.log(result); // Output: 'OK'
|
|
1144
|
+
* ```
|
|
1145
|
+
*/
|
|
1146
|
+
async replicaofNoOne() {
|
|
1147
|
+
return this.createWritePromise((0, Commands_1.createReplicaOfNoOne)(), {
|
|
1148
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
// TODO #6166: move to shared base
|
|
1152
|
+
/**
|
|
1153
|
+
* Returns a report about memory problems detected by the server.
|
|
1154
|
+
*
|
|
1155
|
+
* @see {@link https://valkey.io/commands/memory-doctor/|valkey.io} for details.
|
|
1156
|
+
*
|
|
1157
|
+
* @returns The memory diagnostic report.
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```typescript
|
|
1161
|
+
* const report = await client.memoryDoctor();
|
|
1162
|
+
* console.log(report); // Output: "Sam, I have no memory problems"
|
|
1163
|
+
* ```
|
|
1164
|
+
*/
|
|
1165
|
+
async memoryDoctor() {
|
|
1166
|
+
return this.createWritePromise((0, Commands_1.createMemoryDoctor)(), {
|
|
1167
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Returns the internal statistics of the memory allocator.
|
|
1172
|
+
*
|
|
1173
|
+
* @see {@link https://valkey.io/commands/memory-malloc-stats/|valkey.io} for details.
|
|
1174
|
+
*
|
|
1175
|
+
* @returns The memory allocator statistics.
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```typescript
|
|
1179
|
+
* const stats = await client.memoryMallocStats();
|
|
1180
|
+
* console.log(stats);
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
async memoryMallocStats() {
|
|
1184
|
+
return this.createWritePromise((0, Commands_1.createMemoryMallocStats)(), {
|
|
1185
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Asks the server to reclaim memory from the allocator back to the operating system.
|
|
1190
|
+
*
|
|
1191
|
+
* @see {@link https://valkey.io/commands/memory-purge/|valkey.io} for details.
|
|
1192
|
+
*
|
|
1193
|
+
* @returns `"OK"`.
|
|
1194
|
+
*
|
|
1195
|
+
* @example
|
|
1196
|
+
* ```typescript
|
|
1197
|
+
* const result = await client.memoryPurge();
|
|
1198
|
+
* console.log(result); // Output: 'OK'
|
|
1199
|
+
* ```
|
|
1200
|
+
*/
|
|
1201
|
+
async memoryPurge() {
|
|
1202
|
+
return this.createWritePromise((0, Commands_1.createMemoryPurge)(), {
|
|
1203
|
+
decoder: BaseClient_1.Decoder.String,
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Returns detailed memory consumption statistics of the server.
|
|
1208
|
+
*
|
|
1209
|
+
* @see {@link https://valkey.io/commands/memory-stats/|valkey.io} for details.
|
|
1210
|
+
*
|
|
1211
|
+
* @returns A {@link MemoryStats} object containing detailed memory usage statistics.
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```typescript
|
|
1215
|
+
* const stats = await client.memoryStats();
|
|
1216
|
+
* console.log(stats.peakAllocated); // Peak memory in bytes
|
|
1217
|
+
* console.log(stats.totalAllocated); // Total allocated memory in bytes
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
async memoryStats() {
|
|
1221
|
+
return this.createWritePromise((0, Commands_1.createMemoryStats)()).then((res) => (0, Commands_1.parseMemoryStatsResponse)((0, BaseClient_1.convertGlideRecordToRecord)(res)));
|
|
1222
|
+
}
|
|
850
1223
|
}
|
|
851
1224
|
exports.GlideClient = GlideClient;
|