/// <summary> /// Creates the save item instance. /// </summary> /// <param name="cacheItemName">Name of the cache item.</param> /// <returns></returns> private static CacheItemContainer CreateSaveItemInstance(string cacheItemName) { // we try to get the item from a if (!ContinuousCacheAccessSynchronizationManager.IsCacheItemContainerInitialized(cacheItemName)) { ICacheItem item = _StaticCacheController.GetCacheItem(cacheItemName); // throw exception if the element was not found if (item == null) { throw new CachingException("Cache object \"" + cacheItemName + "\" not found at the CacheElementCollection."); } if (item.IsClustered) { throw new CachingException("Cache Configuration item with key " + cacheItemName + " is configured as clustered. SlimCacheManager does not support clustered cache items. Use CacheManager instead."); } // get the global cachesettings if (item.Minutes < 0 && item.Seconds < 0 && item.LifeSpan.TotalMilliseconds <= 0) { item.Minutes = _StaticCacheController.Minutes; } if (item.LifeSpan == TimeSpan.Zero) { throw new CachingException("Cache Configuration item with key " + cacheItemName + " has no expiry time specified. Either set the Seconds or Minutes value. It is allowed to set both values at a time."); } CacheMode cacheMode; if (item.IsMemcached) { if (item.UseProtocolBufferSerialization) { cacheMode = CacheMode.MemcachedProtocolBufferSerialization; } else { cacheMode = CacheMode.Memcached; } } else { cacheMode = CacheMode.InProcess; } CacheItemContainer container = new CacheItemContainer( item , string.IsNullOrEmpty(item.CacheKey) ? item.Name : item.CacheKey , cacheMode , _StaticCacheController.ContinuousAccessStaleKeySuffixForMemcached); ContinuousCacheAccessSynchronizationManager.InitializeCacheItemSynchronizationController(container); } return(ContinuousCacheAccessSynchronizationManager.GetCacheItemContainer(cacheItemName)); }
private static ICacheItem CreateSaveItemInstance(ICacheController controller, string configSectionKey, string iterationKey) { ICacheItem item = controller.GetCacheItem(configSectionKey); // throw exception if the element was not found if (item == null) { throw new CachingException("Cache object \"" + configSectionKey + "\" not found at the CacheElementCollection."); } if (item.IsIterating && string.IsNullOrEmpty(iterationKey)) { throw new CachingException("Iteration key not provided for an iterating cache item"); } // get the global cachesettings if (item.Minutes < 0 && item.Seconds < 0) { item.Minutes = controller.Minutes; } return(item); }