Esempio n. 1
0
        public CacheManager(string className, AllItemsEnumerator allItemsEnumerator, ItemIdentifier itemIdentifier, CacheDurability durability)
        {
            isAllItemCache          = true;
            this.className          = className;
            this.allItemsEnumerator = allItemsEnumerator;
            this.itemIdentifier     = itemIdentifier;
            this.durability         = durability;
            TimeSpan duration = TimeSpan.Parse(ConfigurationManager.AppSettings[Enum.GetName(typeof(CacheDurability), durability)]);
            List <T> item     = allItemsEnumerator();

            if (durability != CacheDurability.Indefinite)
            {
                cache.Insert(className, item, null, DateTime.UtcNow.Add(duration), Cache.NoSlidingExpiration);
            }
            else
            {
                cache.Insert(className, item, null, Cache.NoAbsoluteExpiration, duration,
                             delegate(string key, CacheItemUpdateReason reason, out object cachedItem, out CacheDependency dependancy, out DateTime absoluteTime, out TimeSpan newDuration)
                {
                    cachedItem   = cache[key];
                    dependancy   = null;
                    absoluteTime = Cache.NoAbsoluteExpiration;
                    newDuration  = duration;
                    Log(className, CacheLogType.AllItemCacheRefreshed, duration.ToString());
                });
            }
            Log(className, CacheLogType.AllItemCacheStarted, durability.ToString());
        }
Esempio n. 2
0
 public CacheManager(string className, ItemLocator itemLocator, ItemIdentifier itemIdentifier, CacheDurability durability)
 {
     this.className      = className;
     this.itemLocator    = itemLocator;
     this.itemIdentifier = itemIdentifier;
     this.durability     = durability;
     Log(className, CacheLogType.EmptyCacheStarted, durability.ToString());
 }