Ejemplo n.º 1
0
 public void Insert(object key, object value, DateTime expirationDate, TimeSpan slidingExpirationTime)
 {
     _itemsLock.EnterWriteLock();
     try
     {
         _items[key] = new ServerCacheItem(value, expirationDate, slidingExpirationTime);
     }
     finally
     {
         _itemsLock.ExitWriteLock();
     }
 }
Ejemplo n.º 2
0
 public object this[object key]
 {
     get
     {
         _itemsLock.EnterUpgradeableReadLock();
         try
         {
             ServerCacheItem res = (ServerCacheItem)_items[key];
             if (res != null)
             {
                 if (res.SlidingExpirationTime.TotalMilliseconds > 0)
                 {
                     _itemsLock.EnterWriteLock();
                     try
                     {
                         res.LastAccessTime = DateTime.Now;
                     }
                     finally
                     {
                         _itemsLock.ExitWriteLock();
                     }
                 }
                 return res.ItemValue;
             }
             else
             {
                 return null;
             }
         }
         finally
         {
             _itemsLock.ExitUpgradeableReadLock();
         }
     }
     set
     {
         _itemsLock.EnterWriteLock();
         try
         {
             _items[key] = new ServerCacheItem(value);
         }
         finally
         {
             _itemsLock.ExitWriteLock();
         }
     }
 }
Ejemplo n.º 3
0
 public void Insert(object key, object value)
 {
     _itemsLock.EnterWriteLock();
     try
     {
         _items[key] = new ServerCacheItem(value);
     }
     finally
     {
         _itemsLock.ExitWriteLock();
     }
 }