/// <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 LoadSettings()
        {
            var systemSettings = new SystemSettings();

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

            cache.Remove(SystemSettings.CacheKey());
        }
예제 #3
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;
            }
        }