public async Task SetKeyExpiring() { using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri)) { await cache.SetObjectAsKeyValue("test3", new Cat { }, TimeSpan.FromSeconds(5)); bool initialCheck = await cache.KeyExists("test3"); await Task.Delay(TimeSpan.FromSeconds(6)); bool finalCheck = await cache.KeyExists("test3"); Assert.True(initialCheck && !finalCheck); } }
public async Task KeyExistsTest() { using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri)) { await cache.SetObjectAsKeyValue("test6", "test"); bool result = await cache.KeyExists("test6"); await cache.RemoveKey("test6"); Assert.True(result); } }
public async Task <bool> KeyExists(string keyName) { return(await _cacheService.KeyExists(keyName)); }
/// <summary> /// Check to see if a user exists /// </summary> /// <param name="user"><see cref="User"/> object which contains a valid user id</param> /// <returns></returns> public async Task <bool> UserExists(User user) { return(await _cacheService.KeyExists(_userPrefix + user._Id.ToString())); }