@@ -397,7 +397,17 @@ public struct MIGRATE<Host: RESPStringRenderable>: ValkeyCommand {
397
397
public var authentication : Authentication ?
398
398
public var keys : [ ValkeyKey ]
399
399
400
- @inlinable public init ( host: Host , port: Int , keySelector: KeySelector , destinationDb: Int , timeout: Int , copy: Bool = false , replace: Bool = false , authentication: Authentication ? = nil , keys: [ ValkeyKey ] = [ ] ) {
400
+ @inlinable public init (
401
+ host: Host ,
402
+ port: Int ,
403
+ keySelector: KeySelector ,
404
+ destinationDb: Int ,
405
+ timeout: Int ,
406
+ copy: Bool = false ,
407
+ replace: Bool = false ,
408
+ authentication: Authentication ? = nil ,
409
+ keys: [ ValkeyKey ] = [ ]
410
+ ) {
401
411
self . host = host
402
412
self . port = port
403
413
self . keySelector = keySelector
@@ -412,7 +422,18 @@ public struct MIGRATE<Host: RESPStringRenderable>: ValkeyCommand {
412
422
public var keysAffected : [ ValkeyKey ] { keys }
413
423
414
424
@inlinable public func encode( into commandEncoder: inout ValkeyCommandEncoder ) {
415
- commandEncoder. encodeArray ( " MIGRATE " , RESPBulkString ( host) , port, keySelector, destinationDb, timeout, RESPPureToken ( " COPY " , copy) , RESPPureToken ( " REPLACE " , replace) , authentication, RESPWithToken ( " KEYS " , keys) )
425
+ commandEncoder. encodeArray (
426
+ " MIGRATE " ,
427
+ RESPBulkString ( host) ,
428
+ port,
429
+ keySelector,
430
+ destinationDb,
431
+ timeout,
432
+ RESPPureToken ( " COPY " , copy) ,
433
+ RESPPureToken ( " REPLACE " , replace) ,
434
+ authentication,
435
+ RESPWithToken ( " KEYS " , keys)
436
+ )
416
437
}
417
438
}
418
439
@@ -640,7 +661,15 @@ public struct RESTORE<SerializedValue: RESPStringRenderable>: ValkeyCommand {
640
661
public var seconds : Int ?
641
662
public var frequency : Int ?
642
663
643
- @inlinable public init ( key: ValkeyKey , ttl: Int , serializedValue: SerializedValue , replace: Bool = false , absttl: Bool = false , seconds: Int ? = nil , frequency: Int ? = nil ) {
664
+ @inlinable public init (
665
+ key: ValkeyKey ,
666
+ ttl: Int ,
667
+ serializedValue: SerializedValue ,
668
+ replace: Bool = false ,
669
+ absttl: Bool = false ,
670
+ seconds: Int ? = nil ,
671
+ frequency: Int ? = nil
672
+ ) {
644
673
self . key = key
645
674
self . ttl = ttl
646
675
self . serializedValue = serializedValue
@@ -653,7 +682,16 @@ public struct RESTORE<SerializedValue: RESPStringRenderable>: ValkeyCommand {
653
682
public var keysAffected : CollectionOfOne < ValkeyKey > { . init( key) }
654
683
655
684
@inlinable public func encode( into commandEncoder: inout ValkeyCommandEncoder ) {
656
- commandEncoder. encodeArray ( " RESTORE " , key, ttl, RESPBulkString ( serializedValue) , RESPPureToken ( " REPLACE " , replace) , RESPPureToken ( " ABSTTL " , absttl) , RESPWithToken ( " IDLETIME " , seconds) , RESPWithToken ( " FREQ " , frequency) )
685
+ commandEncoder. encodeArray (
686
+ " RESTORE " ,
687
+ key,
688
+ ttl,
689
+ RESPBulkString ( serializedValue) ,
690
+ RESPPureToken ( " REPLACE " , replace) ,
691
+ RESPPureToken ( " ABSTTL " , absttl) ,
692
+ RESPWithToken ( " IDLETIME " , seconds) ,
693
+ RESPWithToken ( " FREQ " , frequency)
694
+ )
657
695
}
658
696
}
659
697
@@ -727,7 +765,15 @@ public struct SORT: ValkeyCommand {
727
765
public var sorting : Bool
728
766
public var destination : ValkeyKey ?
729
767
730
- @inlinable public init ( key: ValkeyKey , byPattern: String ? = nil , limit: Limit ? = nil , getPattern: [ String ] = [ ] , order: Order ? = nil , sorting: Bool = false , destination: ValkeyKey ? = nil ) {
768
+ @inlinable public init (
769
+ key: ValkeyKey ,
770
+ byPattern: String ? = nil ,
771
+ limit: Limit ? = nil ,
772
+ getPattern: [ String ] = [ ] ,
773
+ order: Order ? = nil ,
774
+ sorting: Bool = false ,
775
+ destination: ValkeyKey ? = nil
776
+ ) {
731
777
self . key = key
732
778
self . byPattern = byPattern
733
779
self . limit = limit
@@ -740,7 +786,16 @@ public struct SORT: ValkeyCommand {
740
786
public var keysAffected : [ ValkeyKey ] { ( destination. map { [ $0] } ?? [ ] ) + [ key] }
741
787
742
788
@inlinable public func encode( into commandEncoder: inout ValkeyCommandEncoder ) {
743
- commandEncoder. encodeArray ( " SORT " , key, RESPWithToken ( " BY " , byPattern) , RESPWithToken ( " LIMIT " , limit) , RESPWithToken ( " GET " , getPattern) , order, RESPPureToken ( " ALPHA " , sorting) , RESPWithToken ( " STORE " , destination) )
789
+ commandEncoder. encodeArray (
790
+ " SORT " ,
791
+ key,
792
+ RESPWithToken ( " BY " , byPattern) ,
793
+ RESPWithToken ( " LIMIT " , limit) ,
794
+ RESPWithToken ( " GET " , getPattern) ,
795
+ order,
796
+ RESPPureToken ( " ALPHA " , sorting) ,
797
+ RESPWithToken ( " STORE " , destination)
798
+ )
744
799
}
745
800
}
746
801
@@ -791,7 +846,14 @@ public struct SORTRO: ValkeyCommand {
791
846
public var order : Order ?
792
847
public var sorting : Bool
793
848
794
- @inlinable public init ( key: ValkeyKey , byPattern: String ? = nil , limit: Limit ? = nil , getPattern: [ String ] = [ ] , order: Order ? = nil , sorting: Bool = false ) {
849
+ @inlinable public init (
850
+ key: ValkeyKey ,
851
+ byPattern: String ? = nil ,
852
+ limit: Limit ? = nil ,
853
+ getPattern: [ String ] = [ ] ,
854
+ order: Order ? = nil ,
855
+ sorting: Bool = false
856
+ ) {
795
857
self . key = key
796
858
self . byPattern = byPattern
797
859
self . limit = limit
@@ -805,7 +867,15 @@ public struct SORTRO: ValkeyCommand {
805
867
public var isReadOnly : Bool { true }
806
868
807
869
@inlinable public func encode( into commandEncoder: inout ValkeyCommandEncoder ) {
808
- commandEncoder. encodeArray ( " SORT_RO " , key, RESPWithToken ( " BY " , byPattern) , RESPWithToken ( " LIMIT " , limit) , RESPWithToken ( " GET " , getPattern) , order, RESPPureToken ( " ALPHA " , sorting) )
870
+ commandEncoder. encodeArray (
871
+ " SORT_RO " ,
872
+ key,
873
+ RESPWithToken ( " BY " , byPattern) ,
874
+ RESPWithToken ( " LIMIT " , limit) ,
875
+ RESPWithToken ( " GET " , getPattern) ,
876
+ order,
877
+ RESPPureToken ( " ALPHA " , sorting)
878
+ )
809
879
}
810
880
}
811
881
@@ -1049,8 +1119,30 @@ extension ValkeyConnectionProtocol {
1049
1119
/// * "OK": Success.
1050
1120
/// * "NOKEY": No keys were found in the source instance.
1051
1121
@inlinable
1052
- public func migrate< Host: RESPStringRenderable > ( host: Host , port: Int , keySelector: MIGRATE < Host > . KeySelector , destinationDb: Int , timeout: Int , copy: Bool = false , replace: Bool = false , authentication: MIGRATE < Host > . Authentication ? = nil , keys: [ ValkeyKey ] = [ ] ) async throws -> String ? {
1053
- try await send ( command: MIGRATE ( host: host, port: port, keySelector: keySelector, destinationDb: destinationDb, timeout: timeout, copy: copy, replace: replace, authentication: authentication, keys: keys) )
1122
+ public func migrate< Host: RESPStringRenderable > (
1123
+ host: Host ,
1124
+ port: Int ,
1125
+ keySelector: MIGRATE < Host > . KeySelector ,
1126
+ destinationDb: Int ,
1127
+ timeout: Int ,
1128
+ copy: Bool = false ,
1129
+ replace: Bool = false ,
1130
+ authentication: MIGRATE < Host > . Authentication ? = nil ,
1131
+ keys: [ ValkeyKey ] = [ ]
1132
+ ) async throws -> String ? {
1133
+ try await send (
1134
+ command: MIGRATE (
1135
+ host: host,
1136
+ port: port,
1137
+ keySelector: keySelector,
1138
+ destinationDb: destinationDb,
1139
+ timeout: timeout,
1140
+ copy: copy,
1141
+ replace: replace,
1142
+ authentication: authentication,
1143
+ keys: keys
1144
+ )
1145
+ )
1054
1146
}
1055
1147
1056
1148
/// Moves a key to another database.
@@ -1244,8 +1336,26 @@ extension ValkeyConnectionProtocol {
1244
1336
/// * 5.0.0: Added the `IDLETIME` and `FREQ` options.
1245
1337
/// - Complexity: O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).
1246
1338
@inlinable
1247
- public func restore< SerializedValue: RESPStringRenderable > ( key: ValkeyKey , ttl: Int , serializedValue: SerializedValue , replace: Bool = false , absttl: Bool = false , seconds: Int ? = nil , frequency: Int ? = nil ) async throws {
1248
- _ = try await send ( command: RESTORE ( key: key, ttl: ttl, serializedValue: serializedValue, replace: replace, absttl: absttl, seconds: seconds, frequency: frequency) )
1339
+ public func restore< SerializedValue: RESPStringRenderable > (
1340
+ key: ValkeyKey ,
1341
+ ttl: Int ,
1342
+ serializedValue: SerializedValue ,
1343
+ replace: Bool = false ,
1344
+ absttl: Bool = false ,
1345
+ seconds: Int ? = nil ,
1346
+ frequency: Int ? = nil
1347
+ ) async throws {
1348
+ _ = try await send (
1349
+ command: RESTORE (
1350
+ key: key,
1351
+ ttl: ttl,
1352
+ serializedValue: serializedValue,
1353
+ replace: replace,
1354
+ absttl: absttl,
1355
+ seconds: seconds,
1356
+ frequency: frequency
1357
+ )
1358
+ )
1249
1359
}
1250
1360
1251
1361
/// Iterates over the key names in the database.
@@ -1270,8 +1380,26 @@ extension ValkeyConnectionProtocol {
1270
1380
/// * [Integer]: When the store option is specified the command returns the number of sorted elements in the destination list.
1271
1381
/// * [Array]: When not passing the store option the command returns a list of sorted elements.
1272
1382
@inlinable
1273
- public func sort( key: ValkeyKey , byPattern: String ? = nil , limit: SORT . Limit ? = nil , getPattern: [ String ] = [ ] , order: SORT . Order ? = nil , sorting: Bool = false , destination: ValkeyKey ? = nil ) async throws -> SORT . Response {
1274
- try await send ( command: SORT ( key: key, byPattern: byPattern, limit: limit, getPattern: getPattern, order: order, sorting: sorting, destination: destination) )
1383
+ public func sort(
1384
+ key: ValkeyKey ,
1385
+ byPattern: String ? = nil ,
1386
+ limit: SORT . Limit ? = nil ,
1387
+ getPattern: [ String ] = [ ] ,
1388
+ order: SORT . Order ? = nil ,
1389
+ sorting: Bool = false ,
1390
+ destination: ValkeyKey ? = nil
1391
+ ) async throws -> SORT . Response {
1392
+ try await send (
1393
+ command: SORT (
1394
+ key: key,
1395
+ byPattern: byPattern,
1396
+ limit: limit,
1397
+ getPattern: getPattern,
1398
+ order: order,
1399
+ sorting: sorting,
1400
+ destination: destination
1401
+ )
1402
+ )
1275
1403
}
1276
1404
1277
1405
/// Returns the sorted elements of a list, a set, or a sorted set.
@@ -1281,7 +1409,14 @@ extension ValkeyConnectionProtocol {
1281
1409
/// - Complexity: O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).
1282
1410
/// - Response: [Array]: A list of sorted elements.
1283
1411
@inlinable
1284
- public func sortRo( key: ValkeyKey , byPattern: String ? = nil , limit: SORTRO . Limit ? = nil , getPattern: [ String ] = [ ] , order: SORTRO . Order ? = nil , sorting: Bool = false ) async throws -> RESPToken . Array {
1412
+ public func sortRo(
1413
+ key: ValkeyKey ,
1414
+ byPattern: String ? = nil ,
1415
+ limit: SORTRO . Limit ? = nil ,
1416
+ getPattern: [ String ] = [ ] ,
1417
+ order: SORTRO . Order ? = nil ,
1418
+ sorting: Bool = false
1419
+ ) async throws -> RESPToken . Array {
1285
1420
try await send ( command: SORTRO ( key: key, byPattern: byPattern, limit: limit, getPattern: getPattern, order: order, sorting: sorting) )
1286
1421
}
1287
1422
0 commit comments