예제 #1
0
        /// <summary>
        /// Removes an entry from the cache.
        /// </summary>
        /// <param name="cacheKey"></param>
        public static void RemoveTemplateCacheEntry(string cacheKey)
        {
            var cacheService = _engine?.TemplateCacheService;

            if (cacheService == null)
            {
                return;
            }

            // Remove the item associated with the specified cache key, if it exists.
            cacheService.RemoveKey(cacheKey);

            // If Lava is generated for a specific page it is cached according to the page theme,
            // so remove instances of the template associated with any active theme.
            var themes = SiteCache.All()
                         .Where(x => x.Theme != null)
                         .Select(x => x.Theme)
                         .Distinct()
                         .ToList();

            foreach (var theme in themes)
            {
                var internalKey = GetWebTemplateCacheKey(cacheKey, theme);

                cacheService.RemoveKey(internalKey);
            }
        }