/// <summary> /// Clears the cache, removes domain cache items and content-url items /// </summary> /// <param name="clearDomains">true to clear all domain cache</param> /// <param name="clearForIds">will clear the URL</param> /// <param name="clearMappedUrls">will clear the cache for all URLs mapped to entities</param> /// <param name="clearGeneratedUrls">clears cache for all generated urls</param> /// <param name="clearAll">Clears all cache</param> public void ClearCache(bool clearDomains = false, HiveId[] clearForIds = null, bool clearMappedUrls = false, bool clearGeneratedUrls = false, bool clearAll = false) { if (clearAll) { ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(DomainListKey); ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(ContentUrlKey + ".+"); ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(HostnameUrlKey + ".+"); ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(EntityMappedKey + ".+"); } else { if (clearMappedUrls) { ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(EntityMappedKey + ".+"); } if (clearDomains) { ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(DomainListKey); } if (clearGeneratedUrls) { ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(ContentUrlKey + ".+"); ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(HostnameUrlKey + ".+"); } if (clearForIds != null && clearForIds.Any()) { foreach (var id in clearForIds) { ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(Regex.Escape(ContentUrlKey + id) + ".*"); ApplicationContext.FrameworkContext.ApplicationCache.InvalidateItems(Regex.Escape(HostnameUrlKey + id) + ".*"); } } } }