public class BroadleafCacheProcessor
extends org.thymeleaf.processor.attr.AbstractAttrProcessor
Allows for a customizable cache mechanism that can be used to avoid expensive Thymeleaf processing for HTML fragments that are static. For high volume sites, even a 30 second cache of pages can have significant overall performance impacts.
When used as in conjunction within a th:substituteby, th:replace or th:include attribute this
will cache the template being included. If used in conjunction with th:remove this will cache all of the child
nodes of the element. If neither of these cases are true, this will cache the current node and all children.
The parameters allowed for this processor include a "cacheTimeout" and "cacheKey". This component will rely on
an implementation of TemplateCacheKeyResolverService to build the actual cacheKey used by the underlying
caching implementation. The parameter named "cacheKey" will be used in the construction of the actual cacheKey
which may rely on variables like
Implementors can create more functional cacheKey mechanisms. For example, Broadleaf Enterprise provides an
additional implementation named EnterpriseCacheKeyResolver with support for additional caching
features.
TemplateCacheKeyResolverService},
SimpleCacheKeyResolver}| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_NAME |
protected net.sf.ehcache.Cache |
cache |
protected TemplateCacheKeyResolverService |
cacheKeyResolver |
protected SystemPropertiesService |
systemPropertiesService |
| Constructor and Description |
|---|
BroadleafCacheProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkCacheForElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element)
If this template was found in cache, adds the response to the element and returns true.
|
protected boolean |
checkExpired(org.thymeleaf.dom.Element element,
net.sf.ehcache.Element cacheElement)
Returns true if the item has been
|
void |
fixElement(org.thymeleaf.dom.Element element,
org.thymeleaf.Arguments arguments) |
net.sf.ehcache.Cache |
getCache() |
protected String |
getFragmentSignatureUnprefixedAttributeName(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element,
String attributeName,
String attributeValue) |
int |
getPrecedence() |
boolean |
isCachingEnabled() |
org.thymeleaf.processor.ProcessorResult |
processAttribute(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element,
String attributeName) |
void |
setCache(net.sf.ehcache.Cache cache) |
protected boolean |
shouldCache(org.thymeleaf.Arguments args,
org.thymeleaf.dom.Element element,
String attributeName) |
doProcess, getMatcherpublic static final String ATTR_NAME
protected net.sf.ehcache.Cache cache
protected SystemPropertiesService systemPropertiesService
protected TemplateCacheKeyResolverService cacheKeyResolver
public void fixElement(org.thymeleaf.dom.Element element,
org.thymeleaf.Arguments arguments)
protected boolean shouldCache(org.thymeleaf.Arguments args,
org.thymeleaf.dom.Element element,
String attributeName)
public org.thymeleaf.processor.ProcessorResult processAttribute(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element,
String attributeName)
processAttribute in class org.thymeleaf.processor.attr.AbstractAttrProcessorprotected boolean checkCacheForElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element)
arguments - element - protected boolean checkExpired(org.thymeleaf.dom.Element element,
net.sf.ehcache.Element cacheElement)
element - cacheElement - protected String getFragmentSignatureUnprefixedAttributeName(org.thymeleaf.Arguments arguments, org.thymeleaf.dom.Element element, String attributeName, String attributeValue)
public int getPrecedence()
getPrecedence in class org.thymeleaf.processor.AbstractProcessorpublic net.sf.ehcache.Cache getCache()
public void setCache(net.sf.ehcache.Cache cache)
public boolean isCachingEnabled()
Copyright © 2014. All Rights Reserved.