Example #1
0
        public static async Task <IEnumerable <T> > CacheGetListAsync <T>(this IDistributedCache source, string key) where T : class
        {
            var cacheValue = await source.CacheGetAsync <IEnumerable <T> >(key);

            if (cacheValue == null)
            {
                return(Enumerable.Empty <T>());
            }
            return(cacheValue as IEnumerable <T>);
        }
Example #2
0
        public static async Task <IEnumerable <T> > CacheRemoveAsync <T>(this IDistributedCache source, string key, Func <T, bool> predicate)
        {
            var list = await source.CacheGetAsync <IEnumerable <T> >(key);

            return(list.RemoveAll(predicate));
        }
Example #3
0
        public static async Task <T> CacheFindAsync <T>(this IDistributedCache source, string key, Func <T, bool> predicate)
        {
            var list = await source.CacheGetAsync <IEnumerable <T> >(key);

            return(list.SingleOrDefault(predicate));
        }
Example #4
0
 static T CacheGet <T>(this IDistributedCache source, string key) where T : class
 {
     return(source.CacheGetAsync <T>(key).Result);
 }