@@ -134,30 +134,35 @@ public void Run()
134134 ]
135135 ) ;
136136
137- // Set expiration on hash fields using raw Execute
138- RedisResult hexpireRes1 = db . Execute ( "HEXPIRE" , "myhash" , 10 , "FIELDS" , 2 , "field1" , "field2" ) ;
139- Console . WriteLine ( string . Join ( ", " , ( RedisValue [ ] ) hexpireRes1 ) ) ;
140- // >>> 1, 1
137+ ExpireResult [ ] hexpireRes1 = db . HashFieldExpire (
138+ "myhash" ,
139+ new RedisValue [ ] { "field1" , "field2" } ,
140+ TimeSpan . FromSeconds ( 10 )
141+ ) ;
142+ Console . WriteLine ( string . Join ( ", " , hexpireRes1 ) ) ;
143+ // >>> Success, Success
141144
142- // Check TTL of the fields using raw Execute
143- RedisResult hexpireRes2 = db . Execute ( "HTTL" , "myhash" , "FIELDS" , 2 , "field1" , "field2" ) ;
144- RedisValue [ ] ttlValues = ( RedisValue [ ] ) hexpireRes2 ;
145- Console . WriteLine ( ttlValues . Length ) ;
146- // >>> 2
145+ long [ ] hexpireRes2 = db . HashFieldGetTimeToLive (
146+ "myhash" ,
147+ new RedisValue [ ] { "field1" , "field2" }
148+ ) ;
149+ Console . WriteLine ( string . Join ( ", " , hexpireRes2 ) ) ;
150+ // >>> 10, 10 (approximately)
147151
148152 // Try to set expiration on non-existent field
149- RedisResult hexpireRes3 = db . Execute ( "HEXPIRE" , "myhash" , 10 , "FIELDS" , 1 , "nonexistent" ) ;
150- Console . WriteLine ( string . Join ( ", " , ( RedisValue [ ] ) hexpireRes3 ) ) ;
151- // >>> -2
153+ ExpireResult [ ] hexpireRes3 = db . HashFieldExpire (
154+ "myhash" ,
155+ new RedisValue [ ] { "nonexistent" } ,
156+ TimeSpan . FromSeconds ( 10 )
157+ ) ;
158+ Console . WriteLine ( string . Join ( ", " , hexpireRes3 ) ) ;
159+ // >>> NoSuchField
152160 // STEP_END
153-
154161 // REMOVE_START
155- RedisValue [ ] expireResult1 = ( RedisValue [ ] ) hexpireRes1 ;
156- RedisValue [ ] expireResult3 = ( RedisValue [ ] ) hexpireRes3 ;
157- Assert . Equal ( "1, 1" , string . Join ( ", " , expireResult1 ) ) ;
158- Assert . Equal ( 2 , ttlValues . Length ) ;
159- Assert . True ( ttlValues . All ( ttl => ( int ) ttl > 0 ) ) ; // TTL should be positive
160- Assert . Equal ( "-2" , string . Join ( ", " , expireResult3 ) ) ;
162+ Assert . Equal ( "Success, Success" , string . Join ( ", " , hexpireRes1 ) ) ;
163+ Assert . Equal ( 2 , hexpireRes2 . Length ) ;
164+ Assert . True ( hexpireRes2 . All ( ttl => ttl > 0 ) ) ; // TTL should be positive
165+ Assert . Equal ( "NoSuchField" , string . Join ( ", " , hexpireRes3 ) ) ;
161166 db . KeyDelete ( "myhash" ) ;
162167 // REMOVE_END
163168 }
0 commit comments