public Cache( CacheOptions options, Func <TKey, Task <TValue> > loaderFunction) { this.SetOptions(options); LoaderFunction = loaderFunction; _keyGates = new ConcurrentDictionary <TKey, KeyGate <TKey> >(); _kvStore = new InMemoryKeyValueStore <TKey, CacheEntry <TValue> >(); this.InitializeFlushTimer(); }
public Cache( IEqualityComparer <TKey> comparer, CacheOptions options, Func <TKey, Task <TValue> > loaderFunction) : this(options, loaderFunction) { if (comparer == null) { throw new ArgumentNullException(nameof(comparer)); } _keyGates = new ConcurrentDictionary <TKey, KeyGate <TKey> >(); _kvStore = new InMemoryKeyValueStore <TKey, CacheEntry <TValue> >(comparer); this.InitializeFlushTimer(); }
private void SetOptions(CacheOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _cacheName = options.CacheName; if (_cacheName == null) { throw new ArgumentNullException(nameof(options.CacheName)); } if (_cacheName.Trim() == string.Empty) { throw new ArgumentException(nameof(options.CacheName) + " may not be blank or white space"); } options.Initialize(); _options = options; }
public Cache( IEqualityComparer <TKey> comparer, CacheOptions options) : this(comparer, options, null) { }
public Cache( CacheOptions options) : this(options, null) { }