@@ -814,13 +814,38 @@ public long SAdd(string setId, byte[] value)
814
814
return SendExpectLong ( Commands . SAdd , setId . ToUtf8Bytes ( ) , value ) ;
815
815
}
816
816
817
+ public long SAdd ( string setId , byte [ ] [ ] values )
818
+ {
819
+ if ( setId == null )
820
+ throw new ArgumentNullException ( "setId" ) ;
821
+ if ( values == null )
822
+ throw new ArgumentNullException ( "values" ) ;
823
+ if ( values . Length == 0 )
824
+ throw new ArgumentException ( "values" ) ;
825
+
826
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . SAdd , setId . ToUtf8Bytes ( ) , values ) ;
827
+ return SendExpectLong ( cmdWithArgs ) ;
828
+ }
817
829
public long SRem ( string setId , byte [ ] value )
818
830
{
819
831
AssertSetIdAndValue ( setId , value ) ;
820
832
821
833
return SendExpectLong ( Commands . SRem , setId . ToUtf8Bytes ( ) , value ) ;
822
834
}
823
835
836
+ public long SRem ( string setId , byte [ ] [ ] values )
837
+ {
838
+ if ( setId == null )
839
+ throw new ArgumentNullException ( "setId" ) ;
840
+ if ( values == null )
841
+ throw new ArgumentNullException ( "values" ) ;
842
+ if ( values . Length == 0 )
843
+ throw new ArgumentException ( "values" ) ;
844
+
845
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . SRem , setId . ToUtf8Bytes ( ) , values ) ;
846
+ return SendExpectLong ( cmdWithArgs ) ;
847
+ }
848
+
824
849
public byte [ ] SPop ( string setId )
825
850
{
826
851
if ( setId == null )
@@ -909,6 +934,11 @@ public byte[] SRandMember(string setId)
909
934
return SendExpectData ( Commands . SRandMember , setId . ToUtf8Bytes ( ) ) ;
910
935
}
911
936
937
+ public byte [ ] [ ] SRandMember ( string setId , int count )
938
+ {
939
+ return SendExpectMultiData ( Commands . SRandMember , setId . ToUtf8Bytes ( ) , count . ToUtf8Bytes ( ) ) ;
940
+ }
941
+
912
942
#endregion
913
943
914
944
@@ -974,10 +1004,25 @@ public long RPush(string listId, byte[] value)
974
1004
return SendExpectLong ( Commands . RPush , listId . ToUtf8Bytes ( ) , value ) ;
975
1005
}
976
1006
977
- public long RPushX ( string listId , byte [ ] value )
978
- {
979
- throw new NotImplementedException ( ) ;
980
- }
1007
+ public long RPush ( string listId , byte [ ] [ ] values )
1008
+ {
1009
+ if ( listId == null )
1010
+ throw new ArgumentNullException ( "listId" ) ;
1011
+ if ( values == null )
1012
+ throw new ArgumentNullException ( "values" ) ;
1013
+ if ( values . Length == 0 )
1014
+ throw new ArgumentException ( "values" ) ;
1015
+
1016
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . RPush , listId . ToUtf8Bytes ( ) , values ) ;
1017
+ return SendExpectLong ( cmdWithArgs ) ;
1018
+ }
1019
+
1020
+ public long RPushX ( string listId , byte [ ] value )
1021
+ {
1022
+ AssertListIdAndValue ( listId , value ) ;
1023
+
1024
+ return SendExpectLong ( Commands . RPushX , listId . ToUtf8Bytes ( ) , value ) ;
1025
+ }
981
1026
982
1027
public long LPush ( string listId , byte [ ] value )
983
1028
{
@@ -986,10 +1031,25 @@ public long LPush(string listId, byte[] value)
986
1031
return SendExpectLong ( Commands . LPush , listId . ToUtf8Bytes ( ) , value ) ;
987
1032
}
988
1033
989
- public long LPushX ( string listId , byte [ ] value )
990
- {
991
- throw new NotImplementedException ( ) ;
992
- }
1034
+ public long LPush ( string listId , byte [ ] [ ] values )
1035
+ {
1036
+ if ( listId == null )
1037
+ throw new ArgumentNullException ( "listId" ) ;
1038
+ if ( values == null )
1039
+ throw new ArgumentNullException ( "values" ) ;
1040
+ if ( values . Length == 0 )
1041
+ throw new ArgumentException ( "values" ) ;
1042
+
1043
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . LPush , listId . ToUtf8Bytes ( ) , values ) ;
1044
+ return SendExpectLong ( cmdWithArgs ) ;
1045
+ }
1046
+
1047
+ public long LPushX ( string listId , byte [ ] value )
1048
+ {
1049
+ AssertListIdAndValue ( listId , value ) ;
1050
+
1051
+ return SendExpectLong ( Commands . LPushX , listId . ToUtf8Bytes ( ) , value ) ;
1052
+ }
993
1053
994
1054
public void LTrim ( string listId , int keepStartingFrom , int keepEndingAt )
995
1055
{
@@ -1175,13 +1235,65 @@ public long ZAdd(string setId, long score, byte[] value)
1175
1235
return SendExpectLong ( Commands . ZAdd , setId . ToUtf8Bytes ( ) , score . ToUtf8Bytes ( ) , value ) ;
1176
1236
}
1177
1237
1238
+ public long ZAdd ( string setId , List < KeyValuePair < byte [ ] , double > > pairs )
1239
+ {
1240
+ if ( setId == null )
1241
+ throw new ArgumentNullException ( "setId" ) ;
1242
+ if ( pairs == null )
1243
+ throw new ArgumentNullException ( "pairs" ) ;
1244
+ if ( pairs . Count == 0 )
1245
+ throw new ArgumentOutOfRangeException ( "pairs" ) ;
1246
+
1247
+ var mergedBytes = new byte [ 2 + pairs . Count * 2 ] [ ] ;
1248
+ mergedBytes [ 0 ] = Commands . ZAdd ;
1249
+ mergedBytes [ 1 ] = setId . ToUtf8Bytes ( ) ;
1250
+ for ( var i = 0 ; i < pairs . Count ; i ++ )
1251
+ {
1252
+ mergedBytes [ i * 2 + 2 ] = pairs [ i ] . Value . ToFastUtf8Bytes ( ) ;
1253
+ mergedBytes [ i * 2 + 3 ] = pairs [ i ] . Key ;
1254
+ }
1255
+ return SendExpectLong ( mergedBytes ) ;
1256
+ }
1257
+
1258
+ public long ZAdd ( string setId , List < KeyValuePair < byte [ ] , long > > pairs )
1259
+ {
1260
+ if ( setId == null )
1261
+ throw new ArgumentNullException ( "setId" ) ;
1262
+ if ( pairs == null )
1263
+ throw new ArgumentNullException ( "pairs" ) ;
1264
+ if ( pairs . Count == 0 )
1265
+ throw new ArgumentOutOfRangeException ( "pairs" ) ;
1266
+
1267
+ var mergedBytes = new byte [ 2 + pairs . Count * 2 ] [ ] ;
1268
+ mergedBytes [ 0 ] = Commands . ZAdd ;
1269
+ mergedBytes [ 1 ] = setId . ToUtf8Bytes ( ) ;
1270
+ for ( var i = 0 ; i < pairs . Count ; i ++ )
1271
+ {
1272
+ mergedBytes [ i * 2 + 2 ] = pairs [ i ] . Value . ToUtf8Bytes ( ) ;
1273
+ mergedBytes [ i * 2 + 3 ] = pairs [ i ] . Key ;
1274
+ }
1275
+ return SendExpectLong ( mergedBytes ) ;
1276
+ }
1277
+
1178
1278
public long ZRem ( string setId , byte [ ] value )
1179
1279
{
1180
1280
AssertSetIdAndValue ( setId , value ) ;
1181
1281
1182
1282
return SendExpectLong ( Commands . ZRem , setId . ToUtf8Bytes ( ) , value ) ;
1183
1283
}
1184
1284
1285
+ public long ZRem ( string setId , byte [ ] [ ] values )
1286
+ {
1287
+ if ( setId == null )
1288
+ throw new ArgumentNullException ( "setId" ) ;
1289
+ if ( values == null )
1290
+ throw new ArgumentNullException ( "values" ) ;
1291
+ if ( values . Length == 0 )
1292
+ throw new ArgumentException ( "values" ) ;
1293
+
1294
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . ZRem , setId . ToUtf8Bytes ( ) , values ) ;
1295
+ return SendExpectLong ( cmdWithArgs ) ;
1296
+ }
1185
1297
public double ZIncrBy ( string setId , double incrBy , byte [ ] value )
1186
1298
{
1187
1299
AssertSetIdAndValue ( setId , value ) ;
@@ -1507,6 +1619,18 @@ public long HDel(string hashId, byte[] key)
1507
1619
return SendExpectLong ( Commands . HDel , hashId . ToUtf8Bytes ( ) , key ) ;
1508
1620
}
1509
1621
1622
+ public long HDel ( string hashId , byte [ ] [ ] keys )
1623
+ {
1624
+ if ( hashId == null )
1625
+ throw new ArgumentNullException ( "hashId" ) ;
1626
+ if ( keys == null )
1627
+ throw new ArgumentNullException ( "keys" ) ;
1628
+ if ( keys . Length == 0 )
1629
+ throw new ArgumentException ( "keys" ) ;
1630
+
1631
+ var cmdWithArgs = MergeCommandWithArgs ( Commands . HDel , hashId . ToUtf8Bytes ( ) , keys ) ;
1632
+ return SendExpectLong ( cmdWithArgs ) ;
1633
+ }
1510
1634
public long HExists ( string hashId , byte [ ] key )
1511
1635
{
1512
1636
AssertHashIdAndKey ( hashId , key ) ;
0 commit comments