Exemple #1
0
        /// <inheritdoc/>
        public virtual bool TryGetItem(TKey key, bool markAsHit, out TItem item)
        {
            KeyValuePair <TKey, TItem> cached;

            if (deque.TryGetValue(key, markAsHit, out cached))
            {
                item = cached.Value;
                return(true);
            }
            if (chainedCache == null)
            {
                item = default(TItem);
                return(false);
            }
            if (chainedCache.TryGetItem(key, false, out item))
            {
                chainedCache.Remove(item);
                Add(item, true);
                return(true);
            }
            return(false);
        }
Exemple #2
0
        /// <inheritdoc/>
        public override bool TryGetItem(TKey key, bool markAsHit, out TItem item)
        {
            TCached cached;

            if (deque.TryGetValue(key, markAsHit, out cached))
            {
                item = cacheConverter.ConvertBackward(cached);
                return(true);
            }
            if (chainedCache == null)
            {
                item = default(TItem);
                return(false);
            }
            if (chainedCache.TryGetItem(key, false, out item))
            {
                chainedCache.Remove(item);
                Add(item, true);
                return(true);
            }
            return(false);
        }