Exemple #1
0
 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();
         });
     }
 }
Exemple #2
0
        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);
        }