Class PageCacheManager

  • All Implemented Interfaces:
    IPageCacheManager, IPageCacheManagerSPI

    public class PageCacheManager
    extends java.lang.Object
    implements IPageCacheManagerSPI
    Manager for page cache information.
    Since:
    4.0.0
    Version:
    $Revision: 25808 $ $Date: 2023-07-04 15:20:55 -0300 (Tue, 04 Jul 2023) $
    • Field Detail

      • lastExcessiveCleaningTimestamp

        public static java.lang.Long lastExcessiveCleaningTimestamp
      • PAGE_CACHE_MANAGER_LANGUAGE_FILENAME_PREFIX

        public static final java.lang.String PAGE_CACHE_MANAGER_LANGUAGE_FILENAME_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • PageCacheManager

        public PageCacheManager()
    • Method Detail

      • waitForGeneration

        public java.lang.String waitForGeneration​(java.lang.String pageCacheId,
                                                  long timeout)
                                           throws PortalException,
                                                  java.lang.InterruptedException
        Description copied from interface: IPageCacheManager
        Waits for the generation of a page cache.
        Specified by:
        waitForGeneration in interface IPageCacheManager
        Parameters:
        pageCacheId - the page cache identifier.
        timeout - maximum time to wait.
        Returns:
        the generated page content.
        Throws:
        java.lang.InterruptedException - if the thread was interrupted.
        PortalException
      • waitForPagesReadyToGenerate

        public void waitForPagesReadyToGenerate​(long timeout,
                                                boolean forImmediateUseOnly)
                                         throws java.lang.InterruptedException
        Description copied from interface: IPageCacheManager
        Waits for new pages to be ready to be generated.
        Specified by:
        waitForPagesReadyToGenerate in interface IPageCacheManager
        Parameters:
        timeout - maximum time to wait.
        forImmediateUseOnly - if true, wait until a page for immediate use is ready to generate. If false, wait until any page is ready to generate.
        Throws:
        java.lang.InterruptedException - if the thread was interrupted.
      • doHttpAccess

        protected PageCacheManager.HttpAccessResult doHttpAccess​(java.net.URL url,
                                                                 java.lang.String cookies,
                                                                 PageCacheConfig pageCacheConfig)
                                                          throws java.io.UnsupportedEncodingException,
                                                                 java.io.IOException,
                                                                 PortalException,
                                                                 lumis.portal.page.cache.ContentNotPublishedException
        Throws:
        java.io.UnsupportedEncodingException
        java.io.IOException
        PortalException
        lumis.portal.page.cache.ContentNotPublishedException
      • generateNextPage

        public PageCacheConfig generateNextPage​(lumis.portal.page.cache.GenerationSelectStrategy generationSelectStrategy)
                                         throws PortalException,
                                                lumis.portal.page.cache.ContentNotPublishedException
        Generates next outdated page cache, according to the given strategy. If the generation lock could not be obtained, the page is not generated.
        Parameters:
        generationSelectStrategy - contains informations for the strategy for selecting the next to be generated.
        Returns:
        the generated page cache information, or null if the generation lock could not be obtained or if there is no outdated page (as specified in the parameters).
        Throws:
        lumis.portal.page.cache.ContentNotPublishedException
        PortalException
        Since:
        14.0.0
      • generatePage

        public PageCacheConfig generatePage​(java.lang.String pageCacheId)
                                     throws PortalException
        Description copied from interface: IPageCacheManager
        Generates a page cache. If the generation lock could not be obtained, the page is not generated.
        Specified by:
        generatePage in interface IPageCacheManager
        Parameters:
        pageCacheId - the page cache identifier.
        Returns:
        the generated page cache information, or null if the generation lock could not be obtained.
        Throws:
        PortalException
      • deleteHtmlFiles

        protected void deleteHtmlFiles​(IWebsite website,
                                       java.lang.String filePath,
                                       boolean deleteShadowCacheHtml)
        Delete the HTML cache files for the specified path.
        Parameters:
        website - the website from where the file will be deleted.
        filePath - the relative cache file path.
        deleteShadowCacheHtml - if true, the shadow cache file is also deleted.
        Since:
        6.2.0
      • deleteHtmlFiles

        protected void deleteHtmlFiles​(PageCacheConfig pageCache,
                                       boolean deleteShadowCacheHtml)
        Delete the HTML cache files for the specified path.
        Parameters:
        pageCache - the page cache that will have its files deleted.
        deleteShadowCacheHtml - if true, the shadow cache file is also deleted.
        Throws:
        java.io.IOException
        Since:
        6.2.0
      • clearCacheByPagesIds

        public void clearCacheByPagesIds​(SessionConfig sessionConfig,
                                         java.util.Collection<java.lang.String> pagesIds,
                                         java.util.Map<java.lang.String,​java.lang.String[]> parameters,
                                         java.util.Locale locale,
                                         int changeType,
                                         ITransaction transaction)
                                  throws PortalException
        Description copied from interface: IPageCacheManager
        Clear the cache of the specified pages. This method clears the specified pages cache after the transaction commits.
        Specified by:
        clearCacheByPagesIds in interface IPageCacheManager
        Parameters:
        sessionConfig - the user session information.
        pagesIds - a collection of the pages identifiers.
        parameters - the page parameters. Used to filter which caches are cleared.
        locale - specifies the locale to which the cache clearing is to be applied. May be null to indicate any locale.
        changeType - the cause of the cache clear. Must be one of the CLEAR_CACHE_CHANGE_TYPE_* constants.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • clearCacheByChannelIds

        public void clearCacheByChannelIds​(SessionConfig sessionConfig,
                                           java.util.Collection<java.lang.String> channelIds,
                                           java.util.Map<java.lang.String,​java.lang.String[]> parameters,
                                           int changeType,
                                           ITransaction transaction)
                                    throws PortalException
        Description copied from interface: IPageCacheManager
        Clear the cache of the pages within the specified channels recursively. This method will clear the specified pages cache after the transaction commits.
        Specified by:
        clearCacheByChannelIds in interface IPageCacheManager
        Parameters:
        sessionConfig - the user session information.
        parameters - the page parameters. Used to filter which caches are cleared.
        changeType - the cause of the cache clear. Must be one of the CLEAR_CACHE_CHANGE_TYPE_* constants.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • isPageCacheGenerationEnabled

        public boolean isPageCacheGenerationEnabled()
        Description copied from interface: IPageCacheManager
        Indicates if the page cache generation is globally enabled.
        Specified by:
        isPageCacheGenerationEnabled in interface IPageCacheManager
        Returns:
        true if enabled, false otherwise.
      • updateCachedFilesLastModifiedDate

        public void updateCachedFilesLastModifiedDate​(SessionConfig sessionConfig,
                                                      PageConfig pageConfig,
                                                      java.util.Locale locale,
                                                      java.util.Date lastModifiedDate,
                                                      ITransaction transaction)
                                               throws PortalException
        Description copied from interface: IPageCacheManager
        Updates the last modified date of the cached files that match the given pageId and locale.
        Specified by:
        updateCachedFilesLastModifiedDate in interface IPageCacheManager
        Parameters:
        sessionConfig - the user session information.
        pageConfig - the portal page.
        locale - locale for which the cached files needs to be modified.
        lastModifiedDate - date to which the matched files must be modified to.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • pageCacheMissed

        public void pageCacheMissed​(java.lang.String pageCacheId,
                                    boolean forImmediateUse)
                             throws PortalException
        Description copied from interface: IPageCacheManager
        Indicates a miss in the page cache occurred. This provokes an asynchronous page cache generation and causes an increase in its priority due to the interest in accessing it.
        Specified by:
        pageCacheMissed in interface IPageCacheManager
        Parameters:
        pageCacheId - the page cache identifier.
        forImmediateUse - if true, indicates that the missed page cache is required for immediate use. This will greater boost the priority to generate the corresponding page cache.
        Throws:
        PortalException
      • getNextPageForGeneration

        protected PageCacheConfig getNextPageForGeneration​(lumis.portal.page.cache.GenerationSelectStrategy generationSelectStrategy)
                                                    throws PortalException
        Returns the next page cache to be generated. It is locked for generation before being returned.
        Parameters:
        generationSelectStrategy - the strategy to select the cache to be generated.
        Returns:
        the next page cache to be generated, or null if no suitable page was found.
        Throws:
        PortalException
        Since:
        6.0.0
        See Also:
        #getGenerationLock(PageCacheConfig), #releaseGenerationLock(PageCacheConfig, int)
      • clearPageCacheErrors

        public void clearPageCacheErrors​(java.util.Collection<java.lang.String> pageCacheIds,
                                         ITransaction transaction)
                                  throws PortalException
        Description copied from interface: IPageCacheManager
        Clear page cache errors in the database. It is locked for update before being updated.
        Specified by:
        clearPageCacheErrors in interface IPageCacheManager
        Parameters:
        pageCacheIds - the page cache identifiers.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • initializePageCacheConfigurations

        public void initializePageCacheConfigurations()
        Initializes page cache related configurations.

        Populates the database with the page cache related default configurations.

        Since:
        6.0.0
      • recalculateCaches

        public void recalculateCaches​(java.lang.String channelId)
                               throws PortalException
        Recalculates the attributes for the caches in the portal area inside the specified channel.
        Parameters:
        channelId - the channel identifier.
        Throws:
        PortalException
        Since:
        6.0.0
      • enablePageCacheByPageParam

        public void enablePageCacheByPageParam​(java.lang.String paramName,
                                               java.lang.String paramValue,
                                               java.util.Locale locale)
        Enable page cache by a given page parameter name-value pair and locale.
        Parameters:
        paramName - the parameter name.
        paramValue - the parameter value.
        locale - the locale.
        Since:
        10.2.0