public void ExpireKeyTest() { var keyName = KeyName(); const string keyValue = "1.0"; _redisService.Remove(keyName); _redisService.SetString(keyName, keyValue); //check if the key exist var result = _redisService.GetString(keyName); Assert.Equal(keyValue, result); //expire the key _redisService.ExpireKey(keyName, TimeSpan.FromSeconds(2)); Task.Delay(2100).GetAwaiter().GetResult(); //check if the key exist var result2 = _redisService.GetString(keyName); Assert.Null(result2); }