コード例 #1
0
ファイル: HybridCacheService.cs プロジェクト: yhtsnda/spark
        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);
        }
コード例 #2
0
ファイル: DefaultCacheService.cs プロジェクト: yhtsnda/spark
 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);
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
ファイル: HybridCacheService.cs プロジェクト: yhtsnda/spark
 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);
     }
 }
コード例 #6
0
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item)
 {
 }
コード例 #9
0
ファイル: NullCacheService.cs プロジェクト: otac0n/spark
 public void Store(string identifier, CacheExpires expires, ICacheSignal signal, object item)
 {
 }