/// <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); }
/// <summary> /// Flushes this instance. /// </summary> public static void Flush() { RockMemoryCache cache = RockMemoryCache.Default; cache.Remove(SystemSettings.CacheKey()); }
/// <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; } }