Пример #1
0
 /// <summary>
 /// Delete's the given item from the store.
 /// </summary>
 /// <param name="item">The item to delete</param>
 public abstract void Delete(CacheItemInfo item);
Пример #2
0
 /// <summary>
 /// Write the item's data to the store.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="data"></param>
 public abstract void Write(CacheItemInfo info, byte[] data);
Пример #3
0
 /// <summary>
 /// Read the data for the given item.
 /// </summary>
 /// <param name="item">The info describing the item to read</param>
 /// <returns>The data in the store for the specified item.</returns>
 public abstract byte[] Read(CacheItemInfo item);
Пример #4
0
            /// <summary>
            /// Look in the store for a recent entry that we can load from.
            /// </summary>
            /// <returns></returns>
            private bool FindCacheItem()
            {
                lock (this)
                {
                   if (_cacheItemInfo == null && !_thereIsNoCacheItem)
                   {
                  _cacheItemInfo = DataManager.StoreProvider.GetLastestExpiringItem(CacheEntry.UniqueName);
                   }

                   if (_cacheItemInfo == null)
                   {
                  // flat failure.
                  if (!_thereIsNoCacheItem)
                  {
                     _thereIsNoCacheItem = true;
                     Debug.WriteLine("No cache found for {0} (ID={1})", CacheEntry.ObjectType, CacheEntry.LoadContext.Identity);
                  }
                  return false;
                   }
                   return true;
                }
            }
Пример #5
0
            /// <summary>
            /// Save the specified value back to the disk.
            /// </summary>
            /// <param name="uniqueName"></param>
            /// <param name="data"></param>
            /// <param name="updatedTime"></param>
            /// <param name="expirationTime"></param>
            /// <param name="isOptimized"></param>
            public void Save(string uniqueName, byte[] data, DateTime updatedTime, DateTime expirationTime, bool isOptimized)
            {
                if (data == null)
                {
                   throw new ArgumentNullException("data");
                }

                _cacheItemInfo = new CacheItemInfo(uniqueName, updatedTime, expirationTime);
                _cacheItemInfo.IsOptimized = isOptimized;
                Data = null;
                LoadState = DataLoadState.None;

                Debug.WriteLine("Writing cache for {0} (ID={3}), IsOptimized={1}, Will expire {2}", CacheEntry.ObjectType.Name, _cacheItemInfo.IsOptimized, _cacheItemInfo.ExpirationTime, CacheEntry.LoadContext.Identity.ToString());
                DataManager.StoreProvider.Write(_cacheItemInfo, data);
            }
Пример #6
0
 public override void Reset()
 {
     base.Reset();
     _cacheItemInfo = null;
     _thereIsNoCacheItem = false;
 }