Пример #1
0
 /// <summary>
 /// Resets only the variant ExpirationHints.
 /// </summary>
 internal override void ResetVariant(CacheRuntimeContext context)
 {
     for (int i = 0; i < _hints.Count; i++)
     {
         ExpirationHint hint = (ExpirationHint)_hints[i];
         if (hint.IsVariant)
         {
             hint.Reset(context);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Initialize the new hint. if no new hint is specified then dispose the old hint.
 /// </summary>
 /// <param name="oldHint"></param>
 /// <param name="newHint"></param>
 public void ResetHint(ExpirationHint oldHint, ExpirationHint newHint)
 {
     lock (this)
     {
         if (newHint != null)
         {
             if (oldHint != null)
             {
                 ((IDisposable)oldHint).Dispose();                  //dispose only if newHint is not null
             }
             newHint.Reset(_context);
         }
     }
 }
Пример #3
0
        public sealed override bool Add(object key, ExpirationHint eh, OperationContext operationContext)
        {
            if (eh == null)
                return false;
            CacheEntry entry = GetInternal(key, false, operationContext);
            bool result = AddInternal(key, eh, operationContext);
            if (result)
            {
                eh.CacheKey = (string)key;
                if (!eh.Reset(_context))
                {
                    RemoveInternal(key, eh);
                    throw new OperationFailedException("Unable to initialize expiration hint");
                }
                
                _context.ExpiryMgr.UpdateIndex(key, entry.ExpirationHint);
            }

            if (_context.PerfStatsColl != null)
            {
                _context.PerfStatsColl.SetCacheSize(Size);
            }
            return result;
        }
Пример #4
0
 /// <summary>
 /// Initialize the new hint. if no new hint is specified then dispose the old hint.
 /// </summary>
 /// <param name="oldHint"></param>
 /// <param name="newHint"></param>
 public void ResetHint(ExpirationHint oldHint, ExpirationHint newHint)
 {
     lock (this)
     {
         if (newHint != null)
         {
             if (oldHint != null) ((IDisposable)oldHint).Dispose(); //dispose only if newHint is not null
             newHint.Reset(_context);
         }
     }
 }