예제 #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>);
        }
예제 #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));
        }
예제 #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));
        }
예제 #4
0
 static T CacheGet <T>(this IDistributedCache source, string key) where T : class
 {
     return(source.CacheGetAsync <T>(key).Result);
 }