Remove() public method

Removes the specified key.
public Remove ( string key, string regionName = null ) : object
key string The key.
regionName string Name of the region.
return object
Ejemplo n.º 1
0
        /// <summary>
        /// Gets the existing or a new item from cache
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="valueFactory">The value factory.</param>
        /// <returns></returns>
        public static GlobalAttributesCache GetOrAddExisting(string key, Func <GlobalAttributesCache> valueFactory)
        {
            var newValue = new Lazy <GlobalAttributesCache>(valueFactory);
            var oldValue = _cache.AddOrGetExisting(key, newValue, new CacheItemPolicy()) as Lazy <GlobalAttributesCache>;

            try
            {
                return((oldValue ?? newValue).Value);
            }
            catch
            {
                _cache.Remove(key);
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Flushes all the LavaTemplateCache items
        /// </summary>
        public static void Flush()
        {
            RockMemoryCache cache = RockMemoryCache.Default;
            var             lavaTemplateCaches = cache.Where(a => a.Key.StartsWith("Rock:LavaTemplate:"));

            foreach (var lavaTemplateCache in lavaTemplateCaches)
            {
                cache.Remove(lavaTemplateCache.Key);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes Global Attributes from cache
        /// </summary>
        public static void Flush()
        {
            _cache.Remove(GlobalAttributesCache.CacheKey());

            if (HttpContext.Current != null)
            {
                var appSettings = HttpContext.Current.Application;
                appSettings[ORG_LOC_GUID]    = null;
                appSettings[ORG_LOC_STATE]   = null;
                appSettings[ORG_LOC_COUNTRY] = null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Flushes all the pages that use a specific layout.
        /// </summary>
        public static void FlushLayout(int layoutId)
        {
            RockMemoryCache cache = RockMemoryCache.Default;

            foreach (var item in cache)
            {
                if (item.Key.StartsWith("Rock:Page:"))
                {
                    var page = cache[item.Key] as PageCache;
                    if (page != null && page.LayoutId == layoutId)
                    {
                        cache.Remove(item.Key);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the or add existing.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="valueFactory">The value factory.</param>
        /// <returns></returns>
        public static int GetOrAddExisting(string key, Func <int> valueFactory)
        {
            RockMemoryCache cache = RockMemoryCache.Default;

            var newValue = new Lazy <int>(valueFactory);
            var oldValue = cache.AddOrGetExisting(key, newValue, new CacheItemPolicy()) as Lazy <int>;

            try
            {
                return((oldValue ?? newValue).Value);
            }
            catch
            {
                cache.Remove(key);
                throw;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Flushes the cache.
        /// </summary>
        /// <param name="key">The key.</param>
        public static void FlushCache(string key)
        {
            RockMemoryCache cache = RockMemoryCache.Default;

            cache.Remove(key);
        }