Exemple #1
0
        public async Task SearchKeyValues()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                await cache.SetObjectAsKeyValue("user:test2:5", "test1");

                await cache.SetObjectAsKeyValue("user:test2:6", "test2");

                await cache.SetObjectAsKeyValue("user:test2:7", "test3");

                await cache.SetObjectAsKeyValue("user:test2:8", "test4");

                var results = await cache.SearchKeyValues("user:test2*");

                bool resultCheck = results.ContainsValue("test1") && results.ContainsValue("test2") && results.ContainsValue("test3") && results.ContainsValue("test4");

                Assert.Equal(4, results.Count);
                Assert.True(resultCheck);

                foreach (var item in results.Keys)
                {
                    await cache.RemoveKey(item);
                }
            }
        }
Exemple #2
0
        public async Task SearchKeyValuesTyped()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                await cache.SetObjectAsKeyValue("user:test3:9", new Cat { Name = "Ted" });

                await cache.SetObjectAsKeyValue("user:test3:10", new Cat { Name = "Fred" });

                await cache.SetObjectAsKeyValue("user:test3:11", new Cat { Name = "Ned" });

                await cache.SetObjectAsKeyValue("user:test3:12", new Cat { Name = "Bed" });

                var results = await cache.SearchKeyValues <Cat>("user:test3*");

                List <string> resultValues = results.Values.Select(x => x.Name).ToList();

                bool resultCheck = resultValues.Contains("Ted") && resultValues.Contains("Fred") && resultValues.Contains("Ned") && resultValues.Contains("Bed");

                Assert.Equal(4, results.Count);
                Assert.True(resultCheck);

                foreach (var item in results.Keys)
                {
                    await cache.RemoveKey(item);
                }
            }
        }
Exemple #3
0
 public async Task <Dictionary <string, string> > SearchKeysGetValues(string searchTerm)
 {
     return(await _cacheService.SearchKeyValues(searchTerm));
 }