Beispiel #1
0
        /// <summary>
        /// Remove an entry with a given key. Notifies subscriber, if there is any,
        /// of the removed item.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="regionName"></param>
        /// <returns></returns>
        public override object Remove(string key, string regionName = null)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var        cacheKey   = new CacheKey(key);
            CacheEntry cacheValue = null;

            // remove the item, return if not found.
            lock (_locker)
            {
                var mruEntry = MruManager.GetItem(cacheKey);
                if (mruEntry == null)
                {
                    return(null);
                }
                // get the Store's Current Key containing the TimeStamp!
                cacheKey   = (CacheKey)mruEntry.Key;
                cacheValue = mruEntry.Value as CacheEntry;
                MruManager.Remove(cacheKey);
            }
            // Notify the subscriber of the removed item.
            if (CacheEntrySetRemovedCallback != null)
            {
                CacheEntrySetRemovedCallback(new[]
                {
                    new CacheEntryRemovedArguments(this, CacheEntryRemovedReason.Removed, cacheValue.Convert(cacheKey))
                });
            }
            return(cacheValue);
        }