Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public async Task <bool> KeyExists(string keyName)
 {
     return(await _cacheService.KeyExists(keyName));
 }
Exemple #4
0
 /// <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()));
 }