Interface HttpCacheConfig
-
@ProviderType public interface HttpCacheConfigConfiguration for Http cache. Multiple configs can be supplied. Request uri, authentication details, cache store details and invalidation JCR path details are captured through configs. Developer hook supplied for extension of cache config viaHttpCacheConfigExtension
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHttpCacheConfig.FilterScope
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanaccepts(org.apache.sling.api.SlingHttpServletRequest request)Determine if this cache config is applicable for the given request.booleanacceptsRule(String servicePid)Check if the cache config accepts the service pid of the cache handling rule.CacheKeybuildCacheKey(String resourcePath)Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.CacheKeybuildCacheKey(org.apache.sling.api.SlingHttpServletRequest request)Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.booleancanInvalidate(String path)Determines if a JCR path is a candidate for invalidating this cache.StringgetAuthenticationRequirement()Get the authentication requirement for request set for this config.List<Pattern>getBlacklistedRequestUriPatterns()Get the configured list of blacklisted request URIs.StringgetCacheStoreName()Name of the configured cache store.default List<String>getExcludedCookieKeys()Get a list of excluded cookie keys (simple string) of cookies that should NOT be put in the cached response, to be served to the output.default List<Pattern>getExcludedResponseHeaderPatterns()Get a list of headers (as regex pattern) that should NOT be put in the cached response, to be served to the output.default longgetExpiryForAccess()Gets the expiry time for the cache entry access / read.default longgetExpiryForUpdate()Gets the expiry time for the cache entry updated.default longgetExpiryOnCreate()Returns a custom expiry for this config in miliseconds.HttpCacheConfig.FilterScopegetFilterScope()List<Pattern>getJCRInvalidationPathPatterns()Get the configured list of JCR paths that could unvalidate this config.intgetOrder()Gets the order the HttpCacheConfig should be executed in.List<Pattern>getRequestUriPatterns()Get the configured list of whitelisted request URIs.booleanisValid()booleanknows(CacheKey key)Returns true if the key is generated using this cache config.
-
-
-
Method Detail
-
getCacheStoreName
String getCacheStoreName()
Name of the configured cache store.- Returns:
-
getAuthenticationRequirement
String getAuthenticationRequirement()
Get the authentication requirement for request set for this config.- Returns:
- Uses the constants defined in
AuthenticationStatusConfigConstants
-
getRequestUriPatterns
List<Pattern> getRequestUriPatterns()
Get the configured list of whitelisted request URIs.- Returns:
-
getBlacklistedRequestUriPatterns
List<Pattern> getBlacklistedRequestUriPatterns()
Get the configured list of blacklisted request URIs.- Returns:
-
getJCRInvalidationPathPatterns
List<Pattern> getJCRInvalidationPathPatterns()
Get the configured list of JCR paths that could unvalidate this config.- Returns:
-
getExcludedResponseHeaderPatterns
default List<Pattern> getExcludedResponseHeaderPatterns()
Get a list of headers (as regex pattern) that should NOT be put in the cached response, to be served to the output.- Returns:
-
getExcludedCookieKeys
default List<String> getExcludedCookieKeys()
Get a list of excluded cookie keys (simple string) of cookies that should NOT be put in the cached response, to be served to the output. This is useful for example with systems that put a login cookie in each response.- Returns:
-
accepts
boolean accepts(org.apache.sling.api.SlingHttpServletRequest request) throws HttpCacheRepositoryAccessExceptionDetermine if this cache config is applicable for the given request. CallsHttpCacheConfigExtension .accept()for providing share of control to the custom code.- Parameters:
request- the request- Returns:
- true if the response should be cached, false if it should not be cached.
- Throws:
HttpCacheRepositoryAccessException
-
isValid
boolean isValid()
- Returns:
- true if this config is considered valid and processable by the HttpCacheEngine.
-
buildCacheKey
CacheKey buildCacheKey(org.apache.sling.api.SlingHttpServletRequest request) throws HttpCacheKeyCreationException
Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.- Parameters:
request- the request to create the CacheKey for- Returns:
- the CacheKey
- Throws:
HttpCacheKeyCreationException
-
buildCacheKey
CacheKey buildCacheKey(String resourcePath) throws HttpCacheKeyCreationException
Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.- Parameters:
resourcePath- the resourcePath associated with the Cache Key- Returns:
- the CacheKey
- Throws:
HttpCacheKeyCreationException
-
canInvalidate
boolean canInvalidate(String path)
Determines if a JCR path is a candidate for invalidating this cache.- Parameters:
path- the jcr path- Returns:
- true if this config can be invalidated by a change to this path
-
knows
boolean knows(CacheKey key) throws HttpCacheKeyCreationException
Returns true if the key is generated using this cache config.- Parameters:
key-- Returns:
- Throws:
HttpCacheKeyCreationException
-
getOrder
int getOrder()
Gets the order the HttpCacheConfig should be executed in.- Returns:
-
acceptsRule
boolean acceptsRule(String servicePid)
Check if the cache config accepts the service pid of the cache handling rule.- Parameters:
servicePid- Service pid of HttpCacheHandlingRule.- Returns:
- True if it accepts.
-
getFilterScope
HttpCacheConfig.FilterScope getFilterScope()
- Returns:
- the filter scope this HttpCacheConfig should involve itself in.
-
getExpiryOnCreate
default long getExpiryOnCreate()
Returns a custom expiry for this config in miliseconds. -1 means the entry will never expire itself. 0 means the expiry is not set, and the default expiry will be used. 1 or above is the expiry for entries produced by this config .- Returns:
-
getExpiryForAccess
default long getExpiryForAccess()
Gets the expiry time for the cache entry access / read. If set, it will refresh the expiry time when an entry is read with given value. Value is in miliseconds.- Returns:
- the expiry time
-
getExpiryForUpdate
default long getExpiryForUpdate()
Gets the expiry time for the cache entry updated. If set, it will refresh the expiry time when an entry is updated with given value. Value is in miliseconds.- Returns:
- the expiry time
-
-