예제 #1
0
 public CacheItemHolder(
     T value,
     CacheSetting cacheItemInfo)
 {
     this.Value         = value;
     this.cacheItemInfo = cacheItemInfo;
 }
예제 #2
0
        public void Set(string key, object value, CacheSetting itemInfo)
        {
            lock (thisLock)
            {
                DateTime expiredtime = DateTime.Now;

                switch (itemInfo.ExpirationMode)
                {
                case CacheExpirationMode.Absolute:
                    expiredtime = itemInfo.AbsoluteExpiration;
                    break;

                case CacheExpirationMode.Sliding:
                    expiredtime = expiredtime.Add(itemInfo.SlidingExpiration);
                    break;

                case CacheExpirationMode.Never:
                    client.Store(StoreMode.Set, key, value);
                    return;

                default:
                    break;
                }

                client.Store(StoreMode.Set, key, value, expiredtime);
            }
        }
예제 #3
0
 public CacheItemHolder(
     CacheManager cache,
     CacheSetting cacheItemInfo)
 {
     this.cache         = cache;
     this.cacheItemInfo = cacheItemInfo;
 }
예제 #4
0
        public void Set(
            string key,
            object value,
            CacheSetting itemInfo)
        {
            lock ( thisLock )
            {
                OnBeforeValueSet();

                inMemoryCache[key] =
                    new CacheItem(
                        key,
                        value,
                        itemInfo);

                LogCentral.Current.Debug(
                    string.Format(
                        @"[»º³å] ÔÚ'{0}' Ìí¼ÓÁËÒÔϵĻº³å×é: " +
                        @"¼ü(key) ='{1}', Öµ(value) '{2}'.",
                        DateTime.Now,
                        key,
                        inMemoryCache[key].Dump()));

                CheckCurrentSize();

                OnAfterValueSet();
            }
        }
예제 #5
0
        public void Set(
            string key,
            object value,
            CacheSetting itemInfo)
        {
            lock (thisLock)
            {
                DateTime             expiredtime = DateTime.Now;
                ICacheItemExpiration expire      = null;
                switch (itemInfo.ExpirationMode)
                {
                case CacheExpirationMode.Absolute:
                    expiredtime = itemInfo.AbsoluteExpiration;
                    expire      = new CacheItemExpiration(expiredtime);
                    break;

                case CacheExpirationMode.Sliding:
                    expiredtime = expiredtime.Add(itemInfo.SlidingExpiration);
                    expire      = new SlidingCacheItemExpiration(itemInfo.SlidingExpiration);
                    break;

                case CacheExpirationMode.Never:
                    client.Add(key, value);
                    return;

                default:
                    break;
                }

                client.Add(key, value, CacheItemPriority.Normal, new NullCacheItemRefreshAction(), expire);
            }
        }
예제 #6
0
 public CacheItem(
     string key,
     object value,
     CacheSetting cacheInfo)
 {
     this.key       = key;
     this.value     = value;
     this.cacheInfo = cacheInfo;
 }
예제 #7
0
 public virtual void Set(
     string key,
     object value,
     TimeSpan ts)
 {
     lock (thisLock)
     {
         CacheSetting cs = new CacheSetting();
         cs.AbsoluteExpiration = DateTime.Now.Add(ts);
         Set(key, value, cs);
     }
 }
예제 #8
0
 public virtual void Set(
     string key,
     object value,
     DateTime absoluteDateTime)
 {
     lock (thisLock)
     {
         CacheSetting cs = new CacheSetting();
         cs.AbsoluteExpiration = absoluteDateTime;
         Set(key, value, cs);
     }
 }
예제 #9
0
 public virtual void Set(
     string key,
     object value,
     CacheSetting itemInfo)
 {
     lock ( thisLock )
     {
         if (backer != null)
         {
             backer.Set(key, value, itemInfo);
         }
     }
 }
예제 #10
0
 public CacheItemHolder(
     CacheSetting cacheItemInfo)
 {
     this.cacheItemInfo = cacheItemInfo;
 }