@@ -394,7 +394,7 @@ public void Set(string key, byte[] value)
394394 SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value ) ;
395395 }
396396
397- public void Set ( string key , byte [ ] value , int expirySeconds , long expiryMs = 0 , bool ? exists = null )
397+ public void Set ( string key , byte [ ] value , int expirySeconds , long expiryMs = 0 )
398398 {
399399 if ( key == null )
400400 throw new ArgumentNullException ( "key" ) ;
@@ -403,26 +403,24 @@ public void Set(string key, byte[] value, int expirySeconds, long expiryMs = 0,
403403 if ( value . Length > OneGb )
404404 throw new ArgumentException ( "value exceeds 1G" , "value" ) ;
405405
406- if ( exists == null )
407- {
408- if ( expirySeconds > 0 )
409- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
410- else if ( expiryMs > 0 )
411- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) ) ;
412- else
413- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value ) ;
414- }
406+ if ( expirySeconds > 0 )
407+ SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) ) ;
408+ else if ( expiryMs > 0 )
409+ SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) ) ;
415410 else
416- {
417- var entryExists = exists . Value ? Commands . Xx : Commands . Nx ;
418-
419- if ( expirySeconds > 0 )
420- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) , entryExists ) ;
421- else if ( expiryMs > 0 )
422- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) , entryExists ) ;
423- else
424- SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value , entryExists ) ;
425- }
411+ SendExpectSuccess ( Commands . Set , key . ToUtf8Bytes ( ) , value ) ;
412+ }
413+
414+ public bool Set ( string key , byte [ ] value , bool exists , int expirySeconds = 0 , long expiryMs = 0 )
415+ {
416+ var entryExists = exists ? Commands . Xx : Commands . Nx ;
417+
418+ if ( expirySeconds > 0 )
419+ return SendExpectString ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Ex , expirySeconds . ToUtf8Bytes ( ) , entryExists ) == OK ;
420+ if ( expiryMs > 0 )
421+ return SendExpectString ( Commands . Set , key . ToUtf8Bytes ( ) , value , Commands . Px , expiryMs . ToUtf8Bytes ( ) , entryExists ) == OK ;
422+
423+ return SendExpectString ( Commands . Set , key . ToUtf8Bytes ( ) , value , entryExists ) == OK ;
426424 }
427425
428426 public void SetEx ( string key , int expireInSeconds , byte [ ] value )
0 commit comments