}//////获取缓存集合//////缓存Key集合///<returns></returns>publicIDictionary<string,object> GetAll(IEnumerable<string>keys) {if(keys ==null)thrownewArgumentNullException(nameof(keys));vardict =newDictionary<string,object>(); keys.ToList().ForEach(item=>dict.Add(item, Cache.Get(item)));...
keys.Add(cacheItem.Key.ToString()); }returnkeys; }/// /// 获取所有的缓存值/// /// <returns></returns>public List<T> GetAllValues<T>() { var cacheKeys = GetAllKeys(); List<T> vals = new List<T>(); cacheKeys.ForEach(i => { T t;if(_cache.TryGetValue<T>(i, out t)...
SetAll/GetAll 是高吞吐的关键,其中SetAll第二参数支持过期时间,单位秒 var dic = new Dictionary<String, String> { ["111"] = "123", ["222"] = "abc", ["大石头"] = "学无先后达者为师" }; ic.SetAll(dic); var dic2 = ic.GetAll<String>(dic.Keys); Assert.Equal(dic.Count, dic2...
MemoryCache 如何清除全部缓存?,最近有个需求需要定时清理服务器上所有的缓存。本来以为很简单的调用一下MemoryCache.Clear方法就完事了。谁知道MemoryCache类以及IMemoryCache扩展方法都没有Clear方法。这可给难住了,于是想找到所有的Keys来一个个Remove,谁知道居然也
最近有个需求需要定时清理服务器上所有的缓存。本来以为很简单的调用一下 MemoryCache.Clear 方法就完事了。谁知道 MemoryCache 类以及 IMemoryCache 扩展方法都没有 Clear 方法。这可给难住了,于是想找到所有的 Keys 来一个个 Remove ,谁知道居然也没有获取所有 Key...
Int32Count{get; } /// 所有键 ICollectionKeys{get; } #endregion #region基础操作 /// 是否包含缓存项 /// /// BooleanContainsKey(Stringkey); /// 设置缓存项 /// 键 /// 值 /// 过期时间,秒。小于0时采用默认缓存时间 /// BooleanSet(Stringkey,Tvalue,Int32expire=-1); ...
public void DelByPattern(string key) @@ -74,8 +75,18 @@ public List<string> GetAllCacheKeys(string key = default) return keys.Select(u => u.ToString()).ToList(); }var manage = App.GetService<MemoryCacheManager>(false); return manage.GetAllKeys().ToList();...
GetExpire(String key); #endregion #region 集合操作 /// 批量获取缓存项 /// <typeparam name="T"></typeparam> /// /// <returns></returns> IDictionary<String, T> GetAll<T>(IEnumerable<String> keys); /// 批量设置缓存项 /// <typeparam name="T"></typeparam> /// /// 过期时间...
Clear() Removes all keys and values from the cache. Compact(Double) CreateEntry(Object) Creates or overwrites an entry in the cache. Dispose() Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Dispose(Boolean) Disposes the cache and clears ...
GetValues(String, String[]) Gets a set of cache entries that correspond to the specified keys. (Inherited fromObjectCache) MemberwiseClone() Creates a shallow copy of the currentObject. (Inherited fromObject) Remove(String, CacheEntryRemovedReason, String) ...