@@ -456,20 +456,26 @@ public void Set(string key, byte[] value)
456456 }
457457
458458 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 )
459464 {
460465 if ( key == null )
461466 throw new ArgumentNullException ( "key" ) ;
467+
462468 value = value ?? new byte [ 0 ] ;
463469
464470 if ( value . Length > OneGb )
465471 throw new ArgumentException ( "value exceeds 1G" , "value" ) ;
466472
467473 if ( expirySeconds > 0 )
468- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
474+ SendExpectSuccess ( Commands . Set , key , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
469475 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 ( ) ) ;
471477 else
472- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value ) ;
478+ SendExpectSuccess ( Commands . Set , key , value ) ;
473479 }
474480
475481 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
485491 }
486492
487493 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 )
488499 {
489500 if ( key == null )
490501 throw new ArgumentNullException ( "key" ) ;
@@ -493,7 +504,7 @@ public void SetEx(string key, int expireInSeconds, byte[] value)
493504 if ( value . Length > OneGb )
494505 throw new ArgumentException ( "value exceeds 1G" , "value" ) ;
495506
496- SendExpectSuccess ( Commands . SetEx , key . ToUtf8Bytes ( ) , expireInSeconds . ToUtf8Bytes ( ) , value ) ;
507+ SendExpectSuccess ( Commands . SetEx , key , expireInSeconds . ToUtf8Bytes ( ) , value ) ;
497508 }
498509
499510 public bool Persist ( string key )
@@ -553,6 +564,14 @@ public byte[] Get(string key)
553564 return GetBytes ( key ) ;
554565 }
555566
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+
556575 public object [ ] Slowlog ( int ? top )
557576 {
558577 if ( top . HasValue )
@@ -596,11 +615,16 @@ public long Exists(string key)
596615 }
597616
598617 public long Del ( string key )
618+ {
619+ return Del ( key . ToUtf8Bytes ( ) ) ;
620+ }
621+
622+ public long Del ( byte [ ] key )
599623 {
600624 if ( key == null )
601625 throw new ArgumentNullException ( "key" ) ;
602626
603- return SendExpectLong ( Commands . Del , key . ToUtf8Bytes ( ) ) ;
627+ return SendExpectLong ( Commands . Del , key ) ;
604628 }
605629
606630 public long Del ( params string [ ] keys )
@@ -736,19 +760,29 @@ public bool RenameNx(string oldKeyname, string newKeyname)
736760 }
737761
738762 public bool Expire ( string key , int seconds )
763+ {
764+ return Expire ( key . ToUtf8Bytes ( ) , seconds ) ;
765+ }
766+
767+ public bool Expire ( byte [ ] key , int seconds )
739768 {
740769 if ( key == null )
741770 throw new ArgumentNullException ( "key" ) ;
742771
743- return SendExpectLong ( Commands . Expire , key . ToUtf8Bytes ( ) , seconds . ToUtf8Bytes ( ) ) == Success ;
772+ return SendExpectLong ( Commands . Expire , key , seconds . ToUtf8Bytes ( ) ) == Success ;
744773 }
745774
746775 public bool PExpire ( string key , long ttlMs )
776+ {
777+ return PExpire ( key . ToUtf8Bytes ( ) , ttlMs ) ;
778+ }
779+
780+ public bool PExpire ( byte [ ] key , long ttlMs )
747781 {
748782 if ( key == null )
749783 throw new ArgumentNullException ( "key" ) ;
750784
751- return SendExpectLong ( Commands . PExpire , key . ToUtf8Bytes ( ) , ttlMs . ToUtf8Bytes ( ) ) == Success ;
785+ return SendExpectLong ( Commands . PExpire , key , ttlMs . ToUtf8Bytes ( ) ) == Success ;
752786 }
753787
754788 public bool ExpireAt ( string key , long unixTime )
@@ -1969,7 +2003,7 @@ public long ZRemRangeByLex(string setId, string min, string max)
19692003
19702004 #region Hash Operations
19712005
1972- private static void AssertHashIdAndKey ( string hashId , byte [ ] key )
2006+ private static void AssertHashIdAndKey ( object hashId , byte [ ] key )
19732007 {
19742008 if ( hashId == null )
19752009 throw new ArgumentNullException ( "hashId" ) ;
@@ -1978,10 +2012,15 @@ private static void AssertHashIdAndKey(string hashId, byte[] key)
19782012 }
19792013
19802014 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 )
19812020 {
19822021 AssertHashIdAndKey ( hashId , key ) ;
19832022
1984- return SendExpectLong ( Commands . HSet , hashId . ToUtf8Bytes ( ) , key , value ) ;
2023+ return SendExpectLong ( Commands . HSet , hashId , key , value ) ;
19852024 }
19862025
19872026 public long HSetNX ( string hashId , byte [ ] key , byte [ ] value )
@@ -2023,10 +2062,15 @@ public double HIncrbyFloat(string hashId, byte[] key, double incrementBy)
20232062 }
20242063
20252064 public byte [ ] HGet ( string hashId , byte [ ] key )
2065+ {
2066+ return HGet ( hashId . ToUtf8Bytes ( ) , key ) ;
2067+ }
2068+
2069+ public byte [ ] HGet ( byte [ ] hashId , byte [ ] key )
20262070 {
20272071 AssertHashIdAndKey ( hashId , key ) ;
20282072
2029- return SendExpectData ( Commands . HGet , hashId . ToUtf8Bytes ( ) , key ) ;
2073+ return SendExpectData ( Commands . HGet , hashId , key ) ;
20302074 }
20312075
20322076 public byte [ ] [ ] HMGet ( string hashId , params byte [ ] [ ] keys )
@@ -2042,10 +2086,15 @@ public byte[][] HMGet(string hashId, params byte[][] keys)
20422086 }
20432087
20442088 public long HDel ( string hashId , byte [ ] key )
2089+ {
2090+ return HDel ( hashId . ToUtf8Bytes ( ) , key ) ;
2091+ }
2092+
2093+ public long HDel ( byte [ ] hashId , byte [ ] key )
20452094 {
20462095 AssertHashIdAndKey ( hashId , key ) ;
20472096
2048- return SendExpectLong ( Commands . HDel , hashId . ToUtf8Bytes ( ) , key ) ;
2097+ return SendExpectLong ( Commands . HDel , hashId , key ) ;
20492098 }
20502099
20512100 public long HDel ( string hashId , byte [ ] [ ] keys )
0 commit comments