Interface HttpCacheEngine
public interface HttpCacheEngine
Access gateway and controlling module for http cache sub-system. Coordinates with cache store, cache handling rules,
cache configs and cache invalidators.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcacheResponse(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig cacheConfig) Cache the given response.booleandeliverCacheContent(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig cacheConfig) Deliver the response from the cache.getCacheConfig(org.apache.sling.api.SlingHttpServletRequest request) Get the first, based on cache config order, cache config applicable for the given request.getCacheConfig(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig.FilterScope filterScope) Get the first, based on cache config order, cache config applicable for the given request.voidinvalidateCache(String path) Invalidate the cache for the HttpCacheConfig which is interested in the given path.booleanisCacheHit(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig cacheConfig) Check if the given request can be served from available cache.booleanCheck if the supplied JCR repository path has the potential to invalidate cache.booleanisRequestCacheable(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig cacheConfig) Check if the given request is cache-able per custom cache handling rules.wrapResponse(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig httpCacheConfig) Wrap the response so that response stream can be duplicated.
-
Method Details
-
isRequestCacheable
boolean isRequestCacheable(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig cacheConfig) throws HttpCacheRepositoryAccessException Check if the given request is cache-able per custom cache handling rules. Rules hookHttpCacheHandlingRule.onRequestReceive(SlingHttpServletRequest)exposed.- Parameters:
request-cacheConfig-- Returns:
- True if the request is cache-able
- Throws:
HttpCacheRepositoryAccessException
-
getCacheConfig
HttpCacheConfig getCacheConfig(org.apache.sling.api.SlingHttpServletRequest request) throws HttpCacheConfigConflictException, HttpCacheRepositoryAccessException Get the first, based on cache config order, cache config applicable for the given request. Defaults to the Request scope.- Parameters:
request-- Returns:
- Applicable CacheConfig
- Throws:
HttpCacheConfigConflictException- When more than one cache config matches.HttpCacheRepositoryAccessException
-
getCacheConfig
HttpCacheConfig getCacheConfig(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig.FilterScope filterScope) throws HttpCacheConfigConflictException, HttpCacheRepositoryAccessException Get the first, based on cache config order, cache config applicable for the given request.- Parameters:
request-filterScope-- Returns:
- Applicable CacheConfig
- Throws:
HttpCacheConfigConflictException- When more than one cache config matches.HttpCacheRepositoryAccessException
-
isCacheHit
boolean isCacheHit(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig cacheConfig) throws HttpCachePersistenceException, HttpCacheKeyCreationException Check if the given request can be served from available cache.- Parameters:
request-cacheConfig-- Returns:
- True if the given request can be served from cache.
- Throws:
HttpCachePersistenceExceptionHttpCacheKeyCreationException
-
deliverCacheContent
boolean deliverCacheContent(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig cacheConfig) throws HttpCachePersistenceException, HttpCacheKeyCreationException, HttpCacheDataStreamException Deliver the response from the cache. Custom cache handling rule hook.rule.HttpCacheHandlingRule#onCacheDeliver(SlingHttpServletRequest, SlingHttpServletResponse)exposed.- Parameters:
request-response-cacheConfig-- Returns:
- False if cache cannot deliver this.
- Throws:
HttpCachePersistenceExceptionHttpCacheKeyCreationExceptionHttpCacheDataStreamException
-
wrapResponse
HttpCacheServletResponseWrapper wrapResponse(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig httpCacheConfig) throws HttpCacheDataStreamException, HttpCacheKeyCreationException, HttpCachePersistenceException Wrap the response so that response stream can be duplicated.- Parameters:
request-response-httpCacheConfig-- Returns:
- Throws:
HttpCacheDataStreamExceptionHttpCacheKeyCreationExceptionHttpCachePersistenceException
-
cacheResponse
void cacheResponse(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, HttpCacheConfig cacheConfig) throws HttpCacheKeyCreationException, HttpCacheDataStreamException, HttpCachePersistenceException Cache the given response. Custom cache handling rule hook.HttpCacheHandlingRule#onResponseCache(SlingHttpServletRequest, SlingHttpServletResponse)exposed.- Parameters:
request-response-cacheConfig-- Throws:
HttpCacheKeyCreationExceptionHttpCacheDataStreamExceptionHttpCachePersistenceException
-
isPathPotentialToInvalidate
Check if the supplied JCR repository path has the potential to invalidate cache. This can be identified based on theHttpCacheConfig.- Parameters:
path- JCR repository path.- Returns:
-
invalidateCache
void invalidateCache(String path) throws HttpCachePersistenceException, HttpCacheKeyCreationException Invalidate the cache for the HttpCacheConfig which is interested in the given path. Custom cache handling rule hook.HttpCacheHandlingRule#onCacheInvalidate(String)exposed.- Parameters:
path- JCR repository path.- Throws:
HttpCachePersistenceExceptionHttpCacheKeyCreationException
-