Example #1
0
 public CacheEntryIdentifier(string key, LRUCacheOptions options)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     Key = key;
     Id  = options.HashCodeGenerator(key);
 }
Example #2
0
        public static CacheEntry New(string key, object value, TimeSpan timeSpan, LRUCacheOptions options = null)
        {
            var indentifier = new CacheEntryIdentifier(key, options ?? new LRUCacheOptions());

            return(new CacheEntry(indentifier, value, timeSpan));
        }
Example #3
0
 public LRUCacheStore(LRUCacheOptions options)
 {
     wrLock       = new ReaderWriterLockSlim();
     this.options = options;
     cacheEntries = new LRUCollection <CacheEntry>(options.MaxSize, options.DataPersist?.RestoreItems());
 }
Example #4
0
 public LRUCache(LRUCacheOptions options = null, ICacheStore cacheStore = null)
 {
     this.options    = options ?? new LRUCacheOptions();
     this.cacheStore = cacheStore ?? new LRUCacheStore(this.options);
 }