コード例 #1
0
ファイル: RedisClock.cs プロジェクト: jangocheng/Lucky.Core
        public IVolatileToken When(string key, TimeSpan duration)
        {
            var token = new AbsoluteExpirationToken(this, duration);

            timeCache[key] = token;
            return(token);
        }
コード例 #2
0
ファイル: RedisClock.cs プロジェクト: jangocheng/Lucky.Core
        public IVolatileToken WhenUtc(string key, DateTime absoluteUtc)
        {
            var token = new AbsoluteExpirationToken(this, absoluteUtc);

            timeCache[key] = token;
            return(token);
        }
コード例 #3
0
ファイル: RedisClock.cs プロジェクト: jangocheng/Lucky.Core
 private void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     foreach (KeyValuePair <string, IVolatileToken> token in timeCache)
     {
         if (!token.Value.IsCurrent)
         {
             IVolatileToken _token = new AbsoluteExpirationToken(this, TimeSpan.Zero);
             EngineContext.Current.Resolve <ICacheClient>().Remove(token.Key);
             timeCache.TryRemove(token.Key, out _token);
         }
     }
 }
コード例 #4
0
 private void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     foreach (KeyValuePair <string, IVolatileToken> token in timeCache)
     {
         if (!token.Value.IsCurrent)
         {
             IVolatileToken _token = new AbsoluteExpirationToken(this, TimeSpan.Zero);
             MemcachedHelper.GetInstance().Remove(token.Key);
             timeCache.TryRemove(token.Key, out _token);
         }
     }
 }