CacheKey() private static method

private static CacheKey ( ) : string
return string
Example #1
0
        /// <summary>
        /// Returns Global Attributes from cache.  If they are not already in cache, they
        /// will be read and added to cache
        /// </summary>
        /// <returns></returns>
        private static SystemSettings Read()
        {
            string cacheKey = SystemSettings.CacheKey();

            RockMemoryCache cache          = RockMemoryCache.Default;
            SystemSettings  systemSettings = cache[cacheKey] as SystemSettings;

            if (systemSettings != null)
            {
                return(systemSettings);
            }
            else
            {
                systemSettings            = new SystemSettings();
                systemSettings.Attributes = new List <AttributeCache>();

                var rockContext      = new RockContext();
                var attributeService = new Rock.Model.AttributeService(rockContext);

                foreach (Rock.Model.Attribute attribute in attributeService.GetSystemSettings())
                {
                    var attributeCache = AttributeCache.Read(attribute);
                    systemSettings.Attributes.Add(attributeCache);
                }

                cache.Set(cacheKey, systemSettings, new CacheItemPolicy());

                return(systemSettings);
            }
        }
Example #2
0
        /// <summary>
        /// Flushes this instance.
        /// </summary>
        public static void Flush()
        {
            RockMemoryCache cache = RockMemoryCache.Default;

            cache.Remove(SystemSettings.CacheKey());
        }