File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -554,7 +554,7 @@ private long GetExpiration(byte[] key)
554
554
return - 2 ;
555
555
}
556
556
557
- if ( expirationTimes . TryGetValue ( key , out var expiration ) )
557
+ if ( expirationTimes is not null && expirationTimes . TryGetValue ( key , out var expiration ) )
558
558
{
559
559
return expiration ;
560
560
}
Original file line number Diff line number Diff line change @@ -85,6 +85,22 @@ public async Task CanSetWithExpireAndRemoveExpireByCallingSetAgain()
85
85
ClassicAssert . AreEqual ( "Tsavorite" , r ) ;
86
86
}
87
87
88
+ // Covers the fix of #954.
89
+ [ Test ]
90
+ public void CanFieldPersistAndGetTimeToLive ( )
91
+ {
92
+ using var redis = ConnectionMultiplexer . Connect ( TestUtils . GetConfig ( ) ) ;
93
+ var db = redis . GetDatabase ( 0 ) ;
94
+ var key = "user:user1" ;
95
+ var field = "field1" ;
96
+
97
+ db . HashSet ( key , [ new HashEntry ( field , "v1" ) ] ) ;
98
+ db . HashFieldExpire ( key , [ field] , TimeSpan . FromHours ( 1 ) ) ;
99
+ db . HashFieldPersist ( key , [ field] ) ;
100
+ var ttl = db . HashFieldGetTimeToLive ( key , [ field] ) ;
101
+ ClassicAssert . AreEqual ( - 1 , ttl [ 0 ] ) ;
102
+ }
103
+
88
104
[ Test ]
89
105
public void CanSetAndGetOnePairLarge ( )
90
106
{
You can’t perform that action at this time.
0 commit comments