Example #1
0
        public async Task GetEmptyTypesValue()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                Cat value = await cache.GetValueFromKey <Cat>("test4");

                Assert.Null(value);
            }
        }
Example #2
0
        public async Task TypedValueFetch()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                await cache.SetObjectAsKeyValue("test5", new Cat { Name = "Billy", Age = 90 });

                var result = await cache.GetValueFromKey <Cat>("test5");

                await cache.RemoveKey("test5");

                Assert.True(result is Cat && result.Name == "Billy" && result.Age == 90);
            }
        }
Example #3
0
        public async Task SetKey()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                await cache.SetObjectAsKeyValue("test2", "hi!");

                string value = await cache.GetValueFromKey("test2");

                await cache.RemoveKey("test2");

                Assert.Equal("hi!", value);
            }
        }
Example #4
0
        public async Task RemoveKeyWithKey()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                // set
                await cache.SetObjectAsKeyValue("test1", "blah blah blah");

                // remove
                await cache.RemoveKey("test1");

                // check
                string result = await cache.GetValueFromKey("test1");

                // asert
                Assert.Null(result);
            }
        }
Example #5
0
 public async Task <string> FetchKey(string keyName)
 {
     return(await _cacheService.GetValueFromKey(keyName));
 }
Example #6
0
 /// <summary>
 /// Get a user
 /// </summary>
 /// <param name="id"><see cref="string"/> GUID for user.</param>
 /// <returns><see cref="User"/> object</returns>
 public async Task <User> GetUser(string id)
 {
     return(await _cacheService.GetValueFromKey <User>(_userPrefix + id));
 }