@@ -456,20 +456,26 @@ public void Set(string key, byte[] value)
456
456
}
457
457
458
458
public void Set ( string key , byte [ ] value , int expirySeconds , long expiryMs = 0 )
459
+ {
460
+ Set ( key . ToUtf8Bytes ( ) , value , expirySeconds , expiryMs ) ;
461
+ }
462
+
463
+ public void Set ( byte [ ] key , byte [ ] value , int expirySeconds , long expiryMs = 0 )
459
464
{
460
465
if ( key == null )
461
466
throw new ArgumentNullException ( "key" ) ;
467
+
462
468
value = value ?? new byte [ 0 ] ;
463
469
464
470
if ( value . Length > OneGb )
465
471
throw new ArgumentException ( "value exceeds 1G" , "value" ) ;
466
472
467
473
if ( expirySeconds > 0 )
468
- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
474
+ SendExpectSuccess ( Commands . Set , key , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
469
475
else if ( expiryMs > 0 )
470
- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) ) ;
476
+ SendExpectSuccess ( Commands . Set , key , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) ) ;
471
477
else
472
- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value ) ;
478
+ SendExpectSuccess ( Commands . Set , key , value ) ;
473
479
}
474
480
475
481
public bool Set ( string key , byte [ ] value , bool exists , int expirySeconds = 0 , long expiryMs = 0 )
@@ -485,6 +491,11 @@ public bool Set(string key, byte[] value, bool exists, int expirySeconds = 0, lo
485
491
}
486
492
487
493
public void SetEx ( string key , int expireInSeconds , byte [ ] value )
494
+ {
495
+ SetEx ( key . ToUtf8Bytes ( ) , expireInSeconds , value ) ;
496
+ }
497
+
498
+ public void SetEx ( byte [ ] key , int expireInSeconds , byte [ ] value )
488
499
{
489
500
if ( key == null )
490
501
throw new ArgumentNullException ( "key" ) ;
@@ -493,7 +504,7 @@ public void SetEx(string key, int expireInSeconds, byte[] value)
493
504
if ( value . Length > OneGb )
494
505
throw new ArgumentException ( "value exceeds 1G" , "value" ) ;
495
506
496
- SendExpectSuccess ( Commands . SetEx , key . ToUtf8Bytes ( ) , expireInSeconds . ToUtf8Bytes ( ) , value ) ;
507
+ SendExpectSuccess ( Commands . SetEx , key , expireInSeconds . ToUtf8Bytes ( ) , value ) ;
497
508
}
498
509
499
510
public bool Persist ( string key )
@@ -553,6 +564,14 @@ public byte[] Get(string key)
553
564
return GetBytes ( key ) ;
554
565
}
555
566
567
+ public byte [ ] Get ( byte [ ] key )
568
+ {
569
+ if ( key == null )
570
+ throw new ArgumentNullException ( "key" ) ;
571
+
572
+ return SendExpectData ( Commands . Get , key ) ;
573
+ }
574
+
556
575
public object [ ] Slowlog ( int ? top )
557
576
{
558
577
if ( top . HasValue )
@@ -596,11 +615,16 @@ public long Exists(string key)
596
615
}
597
616
598
617
public long Del ( string key )
618
+ {
619
+ return Del ( key . ToUtf8Bytes ( ) ) ;
620
+ }
621
+
622
+ public long Del ( byte [ ] key )
599
623
{
600
624
if ( key == null )
601
625
throw new ArgumentNullException ( "key" ) ;
602
626
603
- return SendExpectLong ( Commands . Del , key . ToUtf8Bytes ( ) ) ;
627
+ return SendExpectLong ( Commands . Del , key ) ;
604
628
}
605
629
606
630
public long Del ( params string [ ] keys )
@@ -736,19 +760,29 @@ public bool RenameNx(string oldKeyname, string newKeyname)
736
760
}
737
761
738
762
public bool Expire ( string key , int seconds )
763
+ {
764
+ return Expire ( key . ToUtf8Bytes ( ) , seconds ) ;
765
+ }
766
+
767
+ public bool Expire ( byte [ ] key , int seconds )
739
768
{
740
769
if ( key == null )
741
770
throw new ArgumentNullException ( "key" ) ;
742
771
743
- return SendExpectLong ( Commands . Expire , key . ToUtf8Bytes ( ) , seconds . ToUtf8Bytes ( ) ) == Success ;
772
+ return SendExpectLong ( Commands . Expire , key , seconds . ToUtf8Bytes ( ) ) == Success ;
744
773
}
745
774
746
775
public bool PExpire ( string key , long ttlMs )
776
+ {
777
+ return PExpire ( key . ToUtf8Bytes ( ) , ttlMs ) ;
778
+ }
779
+
780
+ public bool PExpire ( byte [ ] key , long ttlMs )
747
781
{
748
782
if ( key == null )
749
783
throw new ArgumentNullException ( "key" ) ;
750
784
751
- return SendExpectLong ( Commands . PExpire , key . ToUtf8Bytes ( ) , ttlMs . ToUtf8Bytes ( ) ) == Success ;
785
+ return SendExpectLong ( Commands . PExpire , key , ttlMs . ToUtf8Bytes ( ) ) == Success ;
752
786
}
753
787
754
788
public bool ExpireAt ( string key , long unixTime )
@@ -1969,7 +2003,7 @@ public long ZRemRangeByLex(string setId, string min, string max)
1969
2003
1970
2004
#region Hash Operations
1971
2005
1972
- private static void AssertHashIdAndKey ( string hashId , byte [ ] key )
2006
+ private static void AssertHashIdAndKey ( object hashId , byte [ ] key )
1973
2007
{
1974
2008
if ( hashId == null )
1975
2009
throw new ArgumentNullException ( "hashId" ) ;
@@ -1978,10 +2012,15 @@ private static void AssertHashIdAndKey(string hashId, byte[] key)
1978
2012
}
1979
2013
1980
2014
public long HSet ( string hashId , byte [ ] key , byte [ ] value )
2015
+ {
2016
+ return HSet ( hashId . ToUtf8Bytes ( ) , key , value ) ;
2017
+ }
2018
+
2019
+ public long HSet ( byte [ ] hashId , byte [ ] key , byte [ ] value )
1981
2020
{
1982
2021
AssertHashIdAndKey ( hashId , key ) ;
1983
2022
1984
- return SendExpectLong ( Commands . HSet , hashId . ToUtf8Bytes ( ) , key , value ) ;
2023
+ return SendExpectLong ( Commands . HSet , hashId , key , value ) ;
1985
2024
}
1986
2025
1987
2026
public long HSetNX ( string hashId , byte [ ] key , byte [ ] value )
@@ -2023,10 +2062,15 @@ public double HIncrbyFloat(string hashId, byte[] key, double incrementBy)
2023
2062
}
2024
2063
2025
2064
public byte [ ] HGet ( string hashId , byte [ ] key )
2065
+ {
2066
+ return HGet ( hashId . ToUtf8Bytes ( ) , key ) ;
2067
+ }
2068
+
2069
+ public byte [ ] HGet ( byte [ ] hashId , byte [ ] key )
2026
2070
{
2027
2071
AssertHashIdAndKey ( hashId , key ) ;
2028
2072
2029
- return SendExpectData ( Commands . HGet , hashId . ToUtf8Bytes ( ) , key ) ;
2073
+ return SendExpectData ( Commands . HGet , hashId , key ) ;
2030
2074
}
2031
2075
2032
2076
public byte [ ] [ ] HMGet ( string hashId , params byte [ ] [ ] keys )
@@ -2042,10 +2086,15 @@ public byte[][] HMGet(string hashId, params byte[][] keys)
2042
2086
}
2043
2087
2044
2088
public long HDel ( string hashId , byte [ ] key )
2089
+ {
2090
+ return HDel ( hashId . ToUtf8Bytes ( ) , key ) ;
2091
+ }
2092
+
2093
+ public long HDel ( byte [ ] hashId , byte [ ] key )
2045
2094
{
2046
2095
AssertHashIdAndKey ( hashId , key ) ;
2047
2096
2048
- return SendExpectLong ( Commands . HDel , hashId . ToUtf8Bytes ( ) , key ) ;
2097
+ return SendExpectLong ( Commands . HDel , hashId , key ) ;
2049
2098
}
2050
2099
2051
2100
public long HDel ( string hashId , byte [ ] [ ] keys )
0 commit comments