public static IEnumerable <object> GetEntriesByGroup(this IMemoryCache memoryCache, CacheGroup group) { var flags = BindingFlags.Instance | BindingFlags.NonPublic; var entries = (IDictionary)memoryCache.GetType().GetField("_entries", flags).GetValue(memoryCache); return(entries.Keys.Cast <string>().Where(x => x.ToString().StartsWith(group.GetDescription()))); }
private string GenerateCacheKey(CacheGroup group, object key) => string.Format("{0}.{1}", group.GetDescription(), key);