Interface CacheHelper

  • All Known Implementing Classes:
    DefaultCacheHelper

    public interface CacheHelper
    CacheHelper interface is an user-extensible interface to customize: a) the key generation b) whether to cache the response.
    • Method Detail

      • init

        void init​(jakarta.servlet.ServletContext context,
                  Map<String,​String> props)
           throws Exception
        initialize the helper
        Parameters:
        context - the web application context this helper belongs to
        Throws:
        Exception - if a startup error occurs
      • getCacheKey

        String getCacheKey​(jakarta.servlet.http.HttpServletRequest request)
        getCacheKey: generate the key to be used to cache this request
        Parameters:
        request - incoming HttpServletRequest object
        Returns:
        the generated key for this requested cacheable resource.
      • isCacheable

        boolean isCacheable​(jakarta.servlet.http.HttpServletRequest request)
        isCacheable: is the response to given request cachebale?
        Parameters:
        request - incoming HttpServletRequest object
        Returns:
        true if the response could be cached. or false if the results of this request must not be cached.
      • isRefreshNeeded

        boolean isRefreshNeeded​(jakarta.servlet.http.HttpServletRequest request)
        isRefreshNeeded: is the response to given request be refreshed?
        Parameters:
        request - incoming HttpServletRequest object
        Returns:
        true if the response needs to be refreshed. or return false if the results of this request don't need to be refreshed.
      • getTimeout

        int getTimeout​(jakarta.servlet.http.HttpServletRequest request)
        get timeout for the cached response.
        Parameters:
        request - incoming HttpServletRequest object
        Returns:
        the timeout in seconds for the cached response; a return value of -1 means the response never expires and a value of -2 indicates helper cannot determine the timeout (container assigns default timeout)
      • destroy

        void destroy()
              throws Exception
        Stop the helper from active use
        Throws:
        Exception - if an error occurs