public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { Precondition.Require(key, () => Error.ArgumentNull("key")); Precondition.Require(selector, () => Error.ArgumentNull("selector")); object value; if ((value = Cache.Get(key)) == null) { try { lock (AcquireLock(key)) { if ((value = Cache.Get(key)) == null) { value = selector(); if (value != null) { Cache.Insert(key, value, CreateTagDependency(Cache, tags), expiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } } } finally { ReleaseLock(key); } } return(Converter.ChangeType <T>(value)); }
public virtual T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { Precondition.Defined(key, () => Error.ArgumentNull("key")); Precondition.Require(selector, () => Error.ArgumentNull("selector")); Precondition.Require(!_disposed, () => Error.ObjectDisposed("entries")); _entriesLock.EnterUpgradeableReadLock(); try { CacheEntry entry; if (!TryGetEntryAndValidate(key, out entry)) { _entriesLock.EnterWriteLock(); try { if (!TryGetEntryAndValidate(key, out entry)) { _entries[key] = entry = new CacheEntry(key, selector(), expiration, CreateEntryTags(tags)); } } finally { _entriesLock.ExitWriteLock(); } } return(Converter.ChangeType <T>(entry.Value)); } finally { _entriesLock.ExitUpgradeableReadLock(); } }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { if (tags == null) { return(_provider.Get <T>(key, selector, expiration)); } return(TaggedProvider.Get <T>(key, selector, expiration, tags)); }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { Precondition.Require(selector, () => Error.ArgumentNull("selector")); if (_allowDirtyReads || (tags != null && _invalidations.Overlaps(tags))) { T value = selector(); if (!_allowDirtyReads) { _deferredActions.Add(a => a.Insert(key, value, expiration, tags)); } return(value); } return(_provider.Get(key, selector, expiration, tags)); }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration) { return(_provider.Get <T>(key, selector, expiration)); }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration) { return(Get(key, selector, expiration, null)); }
public T Get <T>(string key, CacheItemSelector <T> selector, TimeSpan timeout, IEnumerable <string> tags) { return(Get <T>(key, selector, timeout, tags)); }
public T Get <T>(string key, CacheItemSelector <T> selector, IEnumerable <string> tags) { return(Get <T>(key, selector, _defaultTimeout, tags)); }
public T Get <T>(string key, CacheItemSelector <T> selector, TimeSpan timeout) { return(Get <T>(key, selector, timeout)); }
public T Get <T>(string key, CacheItemSelector <T> selector) { return(Get <T>(key, selector, _defaultTimeout, null)); }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { return(selector()); }
public T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration) { return(selector()); }
public static T Get <T>(this ITaggedCacheProvider provider, string key, CacheItemSelector <T> selector, DateTime expiration, params string[] tags) { return(provider.Get <T>(key, selector, expiration, tags)); }