public void Add(string key, object value, params ICacheItemExpiration[] expirations) { if (string.IsNullOrEmpty(key)) { throw new ArgumentException("参数[key]不能为空或空字符串"); } CacheItem cacheItemBeforeLock = null; lock (inMemoryCache.SyncRoot) { if (!inMemoryCache.Contains(key)) { cacheItemBeforeLock = new CacheItem(key, value, expirations); inMemoryCache[key] = cacheItemBeforeLock; } else { cacheItemBeforeLock = (CacheItem)inMemoryCache[key]; try { cacheItemBeforeLock.Replace(value, expirations); inMemoryCache[key] = cacheItemBeforeLock; } catch { inMemoryCache.Remove(key); throw; } } } }
public void Initialize(CacheItem owningCacheItem) { }