/// <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);
}
}