Exemple #1
0
 /// <summary>
 /// Creates a new cache based on the given {@link Retriever} and with given maximum size.
 /// </summary>
 /// <param name="retriever">object which can retrieve values for keys</param>
 /// <param name="maxEntries">maximum number of entries the cache will store before evicting some</param>
 public SoftCache(SoftCacheRetriever <K, V> retriever, int maxEntries)
 {
     if (retriever == null)
     {
         throw new ArgumentNullException("retriever is null");
     }
     if (maxEntries < 1)
     {
         throw new ArgumentException("maxEntries must be at least 1");
     }
     cache          = new LRUCacheMap <K, V>(11, maxEntries);
     this.retriever = retriever;
 }
Exemple #2
0
        //private readonly Func<K, V> retrieverFunc;


        /// <summary>
        /// Creates a new cache based on the given {@link Retriever}.
        /// </summary>
        /// <param name="retriever">object which can retrieve values for keys</param>
        public SoftCache(SoftCacheRetriever <K, V> retriever)
            : this(retriever, LRUCacheMap <K, V> .NO_MAX_SIZE)
        {
        }