@@ -396,6 +396,7 @@ public void SetIfGreaterWorksWithoutInitialETag()
396
396
#endregion
397
397
398
398
#region ETAG DEL Happy Paths
399
+
399
400
[ Test ]
400
401
public void DelIfGreaterOnAnAlreadyExistingKeyWithEtagWorks ( )
401
402
{
@@ -590,6 +591,60 @@ private void MakeReadOnly(long untilAddress, IServer server, IDatabase db)
590
591
#endregion
591
592
592
593
#region Edgecases
594
+
595
+ [ Test ]
596
+ [ TestCase ( "m" , "mo" , null ) ] // RCU with no existing exp on noetag key
597
+ [ TestCase ( "mexicanmochawithdoubleespresso" , "c" , null ) ] // IPU with no existing exp on noetag key
598
+ [ TestCase ( "m" , "mo" , 30 ) ] // RCU with existing exp on noetag key
599
+ [ TestCase ( "mexicanmochawithdoubleespresso" , "c" , 30 ) ] // IPU with existing exp on noetag key
600
+ public void SetIfGreaterWhenExpIsSentForExistingNonEtagKey ( string initialValue , string newValue , double ? exp )
601
+ {
602
+ using var redis = ConnectionMultiplexer . Connect ( TestUtils . GetConfig ( ) ) ;
603
+ IDatabase db = redis . GetDatabase ( 0 ) ;
604
+ var key = "meow-key" ;
605
+
606
+ if ( exp != null )
607
+ db . StringSet ( key , initialValue , TimeSpan . FromSeconds ( exp . Value ) ) ;
608
+ else
609
+ db . StringSet ( key , initialValue ) ;
610
+
611
+ RedisResult [ ] arrRes = ( RedisResult [ ] ) db . Execute ( "SETIFGREATER" , key , newValue , 5 , "EX" , 90 ) ;
612
+
613
+ ClassicAssert . AreEqual ( 5 , ( long ) arrRes [ 0 ] ) ;
614
+ ClassicAssert . IsTrue ( arrRes [ 1 ] . IsNull ) ;
615
+
616
+ var res = db . StringGetWithExpiry ( key ) ;
617
+ ClassicAssert . AreEqual ( newValue , res . Value . ToString ( ) ) ;
618
+ ClassicAssert . IsTrue ( res . Expiry . HasValue ) ;
619
+ }
620
+
621
+ [ Test ]
622
+ [ TestCase ( "m" , "mo" , null ) ] // RCU with no existing exp on noetag key
623
+ [ TestCase ( "mexicanmochawithdoubleespresso" , "c" , null ) ] // IPU with no existing exp on noetag key
624
+ [ TestCase ( "m" , "mo" , 30 ) ] // RCU with existing exp on noetag key
625
+ [ TestCase ( "mexicanmochawithdoubleespresso" , "c" , 30 ) ] // IPU with existing exp on noetag key
626
+ public void SetIfMatchWhenExpIsSentForExistingNonEtagKey ( string initialValue , string newValue , int ? exp )
627
+ {
628
+ using var redis = ConnectionMultiplexer . Connect ( TestUtils . GetConfig ( ) ) ;
629
+ IDatabase db = redis . GetDatabase ( 0 ) ;
630
+ var key = "meow-key" ;
631
+
632
+ if ( exp != null )
633
+ db . StringSet ( key , initialValue , TimeSpan . FromSeconds ( exp . Value ) ) ;
634
+ else
635
+ db . StringSet ( key , initialValue ) ;
636
+
637
+ RedisResult [ ] arrRes = ( RedisResult [ ] ) db . Execute ( "SETIFMATCH" , key , newValue , 0 , "EX" , 90 ) ;
638
+
639
+ ClassicAssert . AreEqual ( 1 , ( long ) arrRes [ 0 ] ) ;
640
+ ClassicAssert . IsTrue ( arrRes [ 1 ] . IsNull ) ;
641
+
642
+ var res = db . StringGetWithExpiry ( key ) ;
643
+ ClassicAssert . AreEqual ( newValue , res . Value . ToString ( ) ) ;
644
+ ClassicAssert . IsTrue ( res . Expiry . HasValue ) ;
645
+ }
646
+
647
+
593
648
[ Test ]
594
649
public void SetIfMatchSetsKeyValueOnNonExistingKey ( )
595
650
{
0 commit comments