Beispiel #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);
 }
Beispiel #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));
        }
Beispiel #3
0
 public LRUCacheStore(LRUCacheOptions options)
 {
     wrLock       = new ReaderWriterLockSlim();
     this.options = options;
     cacheEntries = new LRUCollection <CacheEntry>(options.MaxSize, options.DataPersist?.RestoreItems());
 }
Beispiel #4
0
 public LRUCache(LRUCacheOptions options = null, ICacheStore cacheStore = null)
 {
     this.options    = options ?? new LRUCacheOptions();
     this.cacheStore = cacheStore ?? new LRUCacheStore(this.options);
 }