public void Add(TKey key, TValue value) { dicCache[key] = new PersItem <TKey, TValue>(key, value); if (Interlocked.Increment(ref num) > MaxSize) { Task.Factory.StartNew(() => { Check(); }); } }
public bool TryGetValue(TKey key, out TValue value) { PersItem <TKey, TValue> tmp = null; value = default(TValue); if (dicCache.TryGetValue(key, out tmp)) { value = tmp.GetValue(); return(true); } return(false); }