Example #1
0
 public static void setCacheMode(this WebSettings settings, CacheModes value)
 {
     settings.CacheMode = value;
 }
Example #2
0
        private void StoreObjectIntoCache(object cacheObject, string cacheKey, System.Web.HttpContext context, int MinutesToLive, CacheModes cacheMode, System.Web.Caching.CacheItemPriority priority)
        {
            // Only add to the cache when the object is not null
            if (cacheObject != null)
            {
                loggingService.Debug("Storing {0} object {1} into cache", cacheMode.ToString(), cacheKey);

                // Different insert for different cache mode
                switch (cacheMode)
                {
                case CacheModes.Absolute:
                    context.Cache.Insert(cacheKey,
                                         cacheObject,
                                         null,
                                         DateTime.Now.AddMinutes(MinutesToLive),
                                         System.Web.Caching.Cache.NoSlidingExpiration,
                                         priority,
                                         null);
                    break;

                case CacheModes.Sliding:
                    context.Cache.Insert(cacheKey,
                                         cacheObject,
                                         null,
                                         System.Web.Caching.Cache.NoAbsoluteExpiration,
                                         new TimeSpan(0, MinutesToLive, 0),
                                         priority,
                                         null);
                    break;
                }
            }
        }