示例#1
0
        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())));
        }
示例#2
0
 private string GenerateCacheKey(CacheGroup group, object key) => string.Format("{0}.{1}", group.GetDescription(), key);