Exemple #1
0
        /// <summary>
        /// Gets the by prefix.
        /// </summary>
        /// <returns>The by prefix.</returns>
        /// <param name="prefix">Prefix.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public IDictionary <string, CacheValue <T> > GetByPrefix <T>(string prefix) where T : class
        {
            ArgumentCheck.NotNullOrWhiteSpace(prefix, nameof(prefix));

            var localDict = _localCachingProvider.GetByPrefix <T>(prefix);

            //not find in local caching.
            var localNotFindKeys = localDict.Where(x => !x.Value.HasValue).Select(x => x.Key);

            if (localNotFindKeys.Count() <= 0)
            {
                return(localDict);
            }

            try
            {
                foreach (var item in localNotFindKeys)
                {
                    localDict.Remove(item);
                }

                var disDict = _distributedCachingProvider.GetByPrefix <T>(prefix);
                return(localDict.Concat(disDict).ToDictionary(k => k.Key, v => v.Value));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            return(localDict);
        }
Exemple #2
0
        public virtual IEnumerable <BleDevice> GetDiscoveredDevices()
        {
            var all    = (Devices.Select(d => d.Value.Device) ?? new BleDevice[] { }).ToList();
            var cached = _cachingProvider.GetByPrefix <ProxiedBleDevice>(DiscoveredDeviceCachePrefix).Select(v => v.Value.Value.Device);

            all.AddRange(cached);
            return(all?.GroupBy(d => d.Id).Select(grp => grp.First()) ?? new BleDevice[] { });
        }
Exemple #3
0
        protected virtual void GetByPrefix_Should_Succeed()
        {
            _provider.RemoveAll(new List <string> {
                "getbyprefix:key:1", "getbyprefix:key:2"
            });
            var dict = GetMultiDict("getbyprefix:");

            _provider.SetAll(dict, _defaultTs);

            string prefix = "getbyprefix:key:";

            var res = _provider.GetByPrefix <string>(prefix);

            Assert.Equal(2, res.Count);
            Assert.Contains("getbyprefix:key:1", res.Select(x => x.Key));
            Assert.Contains("getbyprefix:key:2", res.Select(x => x.Key));
            Assert.Equal("value1", res.Where(x => x.Key == "getbyprefix:key:1").Select(x => x.Value).FirstOrDefault().Value);
            Assert.Equal("value2", res.Where(x => x.Key == "getbyprefix:key:2").Select(x => x.Value).FirstOrDefault().Value);
        }
Exemple #4
0
        public List <Roulette> GetAll()
        {
            var rouletes = _cachingProvider.GetByPrefix <Roulette>(Key);

            if (rouletes.Values.Count == 0)
            {
                return(new List <Roulette>());
            }
            return(new List <Roulette>(rouletes.Select(x => x.Value.Value)));
        }
        public IEnumerable <RecipeDetails> FindRecipesDetails(RecipeSearchFilterCriteria filterCriteria)
        {
            var filters = _filterFactory.Build(filterCriteria);

            var recipes = _cachingProvider
                          .GetByPrefix <RecipeDetails>(nameof(RecipeDetails))
                          .Values;

            return(recipes
                   .Select(x => x.Value)
                   .Where(x => filters.All(filter => filter.Satisfy(x)))
                   .ToList());
        }
Exemple #6
0
 public IDictionary <string, CacheValue <T> > GetAllByPrefix <T>(string prefix = "")
 {
     return(_provider.GetByPrefix <T>(prefix));
 }
Exemple #7
0
        /// <summary>
        /// Gets the by prefix.
        /// </summary>
        /// <typeparam name="T">Type of cache value</typeparam>
        /// <param name="prefix">Prefix of CacheKey.</param>
        /// <returns>Dictionary of key/value cache items</returns>
        public Dictionary <string, T> GetByPrefix <T>(string prefix)
        {
            var items = _easyCachingProvider.GetByPrefix <T>(prefix);

            return(items.ToDictionary(p => p.Key, p => p.Value.Value));
        }
        public IEnumerable <string> GetUsers()
        {
            var data = easyCachingProvider.GetByPrefix <string>("Basket_").Keys.ToList();

            return(data);
        }