/// <summary> /// Removes Lava shortcode from cache /// </summary> /// <param name="id"></param> public static void Flush(int id) { FlushCache(LavaShortcodeCache.CacheKey(id)); FlushCache("Rock:LavaShortcode:All"); // some of the cached lavatemplates might have a reference to this shortcode, so flush them all just in case LavaTemplateCache.Flush(); }
/// <summary> /// Returns all Lava shortcodes /// </summary> /// <param name="includeInactive">if set to <c>true</c> [include inactive].</param> /// <returns></returns> public static List <LavaShortcodeCache> All(bool includeInactive) { List <LavaShortcodeCache> shortcodes = new List <LavaShortcodeCache>(); var shortcodeIds = GetOrAddExisting("Rock:LavaShortcode:All", () => LoadAll()); if (shortcodeIds != null) { foreach (int shortcodeId in shortcodeIds) { var shortcodeCache = LavaShortcodeCache.Read(shortcodeId); if (shortcodeCache != null) { if (includeInactive || shortcodeCache.IsActive) { shortcodes.Add(shortcodeCache); } } } } return(shortcodes); }
/// <summary> /// Adds lava shortcode model to cache, and returns cached object /// </summary> /// <param name="shortcodeModel"></param> /// <returns></returns> public static LavaShortcodeCache Read(LavaShortcode shortcodeModel) { return(GetOrAddExisting(LavaShortcodeCache.CacheKey(shortcodeModel.Id), () => LoadByModel(shortcodeModel))); }
/// <summary> /// Returns lava shortcode object from cache. If lava shortcode does not already exist in cache, it /// will be read and added to cache /// </summary> /// <param name="id">The identifier.</param> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public static LavaShortcodeCache Read(int id, RockContext rockContext = null) { return(GetOrAddExisting(LavaShortcodeCache.CacheKey(id), () => LoadById(id, rockContext))); }