/// <summary> /// 获取缓存中指定缓存键的对象。 /// </summary> /// <param name="cacheKey">用于引用对象的缓存键。</param> /// <returns>检索到的缓存对象,未找到时为 null。</returns> /// <exception cref="NotSupportedException">不支持该方法。</exception> public object Get(string cacheKey) { if (cacheDictionary.TryGetValue(cacheKey, out CacheItem entry)) { if (optimizer.Update(entry) == null) { if (cacheDictionary.TryRemove(cacheKey, out entry)) { NotifyCacheRemoved(entry); return(null); } } return(entry.Value); } return(null); }
/// <summary> /// 更新缓存项。 /// </summary> /// <param name="cache"></param> /// <param name="checkExpired"></param> /// <returns></returns> internal static CacheItem UpdateEntry(CacheItem cache, bool checkExpired = true) { return(_optimizer.Update(cache, checkExpired)); }