/// <summary> /// Gets the system data entity from the cache. If the entity isn't found in the cache, it's loaded first, stored in the cache and then returned. /// </summary> /// <returns>entity with system data, or null if not found.</returns> public static SystemDataEntity GetSystemData() { Cache activeCache = HttpRuntime.Cache; SystemDataEntity toReturn = (SystemDataEntity)activeCache[CacheKeys.SystemData]; if (toReturn == null) { toReturn = SystemGuiHelper.GetSystemSettings(); if (toReturn != null) { // found, cache it activeCache.Insert(CacheKeys.SystemData, toReturn); } } return(toReturn); }
/// <summary> /// Gets the system data entity from the cache. If the entity isn't found in the cache, it's loaded first, stored in the cache and then returned. /// </summary> /// <param name="cache">The cache object this methods works on</param> /// <returns>entity with system data, or null if not found.</returns> public static async Task <SystemDataEntity> GetSystemDataAsync(this IMemoryCache cache) { var toReturn = cache.Get <SystemDataEntity>(CacheKeys.SystemData); if (toReturn == null) { toReturn = await SystemGuiHelper.GetSystemSettingsAsync(); if (toReturn != null) { // found, cache it cache.Set(CacheKeys.SystemData, toReturn); } } return(toReturn); }