Interface HttpCacheEngine
-
public interface HttpCacheEngineAccess gateway and controlling module for http cache sub-system. Coordinates with cache store, cache handling rules, cache configs and cache invalidators.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcacheResponse(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.HttpCacheConfiggetCacheConfig(org.apache.sling.api.SlingHttpServletRequest request)Get the first, based on cache config order, cache config applicable for the given request.HttpCacheConfiggetCacheConfig(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.booleanisPathPotentialToInvalidate(String path)Check 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.HttpCacheServletResponseWrapperwrapResponse(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 Detail
-
isRequestCacheable
boolean isRequestCacheable(org.apache.sling.api.SlingHttpServletRequest request, HttpCacheConfig cacheConfig) throws HttpCacheRepositoryAccessExceptionCheck 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, HttpCacheKeyCreationExceptionCheck 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, HttpCacheDataStreamExceptionDeliver 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, HttpCachePersistenceExceptionCache the given response. Custom cache handling rule hook.HttpCacheHandlingRule#onResponseCache(SlingHttpServletRequest, SlingHttpServletResponse)exposed.- Parameters:
request-response-cacheConfig-- Throws:
HttpCacheKeyCreationExceptionHttpCacheDataStreamExceptionHttpCachePersistenceException
-
isPathPotentialToInvalidate
boolean isPathPotentialToInvalidate(String path)
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
-
-