private static bool IsSimpleCaching(CacheExpires expires, ICacheSignal signal) { // signal provided - complex caching if (signal != null) { return(false); } // no signal, no expires - simple caching if (expires == null) { return(true); } // expires absolute has meaningful value - complex caching if (expires.Absolute != CacheExpires.NoAbsoluteExpiration && expires.Absolute != DateTime.MaxValue) { return(false); } // expires sliding has meaningful value - complex caching if (expires.Sliding != CacheExpires.NoSlidingExpiration && expires.Sliding != TimeSpan.MaxValue && expires.Sliding != TimeSpan.Zero) { return(false); } // no signal, no meaningful expires value - simple caching return(true); }
public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item) { _cache.Insert( identifier, item, SignalDependency.For(signal), (expires ?? CacheExpires.Empty).Absolute, (expires ?? CacheExpires.Empty).Sliding); }
public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item) { _cache[identifier] = new Entry {Value = item, UtcExpires = ToAbsolute(expires)}; if (signal != null) { signal.Changed += (sender, e) => _cache.Remove(identifier); } }
public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item) { _cache[identifier] = new Entry { Value = item, UtcExpires = ToAbsolute(expires) }; if (signal != null) { signal.Changed += (sender, e) => _cache.Remove(identifier); } }
public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item) { if (IsSimpleCaching(expires, signal)) { // use MR cache service for simple identifier-only caching _monorailCacheProvider.Store(identifier, item); } else { // use the httpcontext cache when storing with expires or signal args in effect _fallbackCacheService.Store(identifier, expires, signal, item); } }
private DateTime ToAbsolute(CacheExpires expires) { // this is less sophisticated than the web caching implementation, but // it only needs to satisfy expectations of unit tests. they should always // use utc for abs if (expires == null) return CacheExpires.NoAbsoluteExpiration; if (expires.Sliding != CacheExpires.NoSlidingExpiration) { return UtcNow.Add(expires.Sliding); } return expires.Absolute; }
private DateTime ToAbsolute(CacheExpires expires) { // this is less sophisticated than the web caching implementation, but // it only needs to satisfy expectations of unit tests. they should always // use utc for abs if (expires == null) { return(CacheExpires.NoAbsoluteExpiration); } if (expires.Sliding != CacheExpires.NoSlidingExpiration) { return(UtcNow.Add(expires.Sliding)); } return(expires.Absolute); }
public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item) { }