コード例 #1
0
ファイル: LavaShortcodeCache.cs プロジェクト: sjison/Rock
        /// <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();
        }
コード例 #2
0
ファイル: LavaShortcodeCache.cs プロジェクト: sjison/Rock
        /// <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);
        }
コード例 #3
0
ファイル: LavaShortcodeCache.cs プロジェクト: sjison/Rock
 /// <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)));
 }
コード例 #4
0
ファイル: LavaShortcodeCache.cs プロジェクト: sjison/Rock
 /// <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)));
 }