/// <summary> /// Try to retrieve an item from the cache /// </summary> /// <param name="key">Key to find the item with.</param> /// <param name="item">Out parameter that will receive the found item.</param> /// <returns>A boolean value indicating if an item has been found.</returns> public bool TryGetItem(TKey key, out TValue item) { object storedItem; bool found = _Level1Cache.TryGetItem(key, out storedItem); if (!found) { var keyAsObject = (object)key; if (keyAsObject != null && _Level2Cache.TryGetValue(keyAsObject, false, out storedItem)) { found = true; _Level1Cache.GetOldestItem(key, ref storedItem); } } if (found) { item = (TValue)storedItem; return(true); } item = default(TValue); return(false); }