Beispiel #1
0
        /// <summary>
        /// Invalidates the current record from the cache.
        /// </summary>
        /// <param name="record">The record</param>
        public void InvalidateRecord(Page record)
        {
            if (Cache.ContainsKey(record.Id))
            {
                Cache.Remove(record.Id);
            }
            // If we click save & publish right away the permalink is not created yet.
            if (record.Permalink != null && PermalinkCache.ContainsKey(record.Permalink))
            {
                PermalinkCache.Remove(record.Permalink);
            }
            if (record.Permalink != null && PermalinkIdCache.ContainsKey(record.PermalinkId))
            {
                PermalinkIdCache.Remove(record.PermalinkId);
            }
            if (record.IsStartpage && Cache.ContainsKey(Guid.Empty))
            {
                Cache.Remove(Guid.Empty);
            }

            // Invalidate public sitemap
            if (!record.IsDraft)
            {
                Sitemap.InvalidateCache();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the page specified by the given permalink.
        /// </summary>
        /// <param name="permalink">The permalink</param>
        /// <param name="draft">Weather to get the current draft</param>
        /// <returns>The page</returns>
        public static Page GetByPermalink(string permalink, bool draft = false)
        {
            if (!draft)
            {
                if (!PermalinkCache.ContainsKey(permalink.ToLower()))
                {
                    Page p = Page.GetSingle("permalink_name = @0 AND page_draft = @1", permalink, draft);

                    if (p != null)
                    {
                        Cache[p.Id] = p;
                        PermalinkCache[p.Permalink]     = p;
                        PermalinkIdCache[p.PermalinkId] = p;
                    }
                }
                return(PermalinkCache.ContainsKey(permalink) ? PermalinkCache[permalink.ToLower()] : null);
            }
            return(Page.GetSingle("permalink_name = @0 AND page_draft = @1", permalink, draft));
        }