/// <summary> /// Initializes a new instance of the <see cref="CachingWrapper{TKey,TValue}"/> class. /// </summary> /// <param name="originalSourceRetriever">The method that will return an element if it is not in the cache.</param> /// <param name="capacity">The maximum capacity of the cache. Use zero for infinite, non LRU capacity</param> public CachingWrapper(RetrieveFromOriginalSource originalSourceRetriever, int capacity) { if (originalSourceRetriever == null) { throw new ArgumentException("originalSourcerRetriever cannot be null"); } _originalSourceRetriever += originalSourceRetriever; _capacity = capacity; if (capacity > 0) { _localCache = new Dictionary<TKey, TValue>(capacity); _lruList = new IndexedLinkedList<TKey>(); } else { _localCache = new Dictionary<TKey, TValue>(); } }
/// <summary> /// Initializes a new instance of the <see cref="CachingWrapper{TKey,TValue}"/> class. /// </summary> /// <param name="originalSourceRetriever">The method that will return an element if it is not in the cache.</param> public CachingWrapper(RetrieveFromOriginalSource originalSourceRetriever : this(originalSourceRetriever, 0) { }