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