Package org.thymeleaf.cache
Class StandardCacheManager
- java.lang.Object
-
- org.thymeleaf.cache.AbstractCacheManager
-
- org.thymeleaf.cache.StandardCacheManager
-
- All Implemented Interfaces:
ICacheManager
public class StandardCacheManager extends AbstractCacheManager
Standard implementation of
ICacheManager, returning configurable instances ofStandardCachefor each of the default caches defined at the cache manager interface.Each cache allows the configuration of the following parameters:
- Its name (will be displayed in logs).
- Its initial size: the size the cache will be initialized with.
- Its maximum size: the maximum size the cache will be allowed to reach.
Some special values:
-1means no limit in size.0means this cache will not be used at all (getXCache()will returnnull).
- Whether the cache should use soft references or not
(
java.lang.ref.SoftReference). Using Soft References allows the cache to be memory-sensitive, allowing the garbage collector to dispose cache entries if memory is critical, before raising anOutOfMemoryError. - The name of the logger that will output trace information for the
cache object. Configuring this allows a finer-grained log configuration that
allows the more effective inspection of cache behaviour. If not specifically
set,
org.thymeleaf.TemplateEngine.cache.${cacheName}will be used. - An (optional) validity checker implementing
ICacheEntryValidityChecker, which will be applied on each entry upon retrieval from cache in order to ensure it is still valid and can be used.
Note a class with this name existed since 2.0.0, but it was completely reimplemented in Thymeleaf 3.0
- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_EXPRESSION_CACHE_ENABLE_COUNTERSDefault expression cache "enable counters" flag: falsestatic intDEFAULT_EXPRESSION_CACHE_INITIAL_SIZEDefault expression cache initial size: 100static java.lang.StringDEFAULT_EXPRESSION_CACHE_LOGGER_NAMEDefault expression cache logger name: null (default behaviour = org.thymeleaf.TemplateEngine.cache.EXPRESSION_CACHE)static intDEFAULT_EXPRESSION_CACHE_MAX_SIZEDefault expression cache maximum size: 500static java.lang.StringDEFAULT_EXPRESSION_CACHE_NAMEDefault expression cache name: "EXPRESSION_CACHE"static booleanDEFAULT_EXPRESSION_CACHE_USE_SOFT_REFERENCESDefault expression cache "use soft references" flag: truestatic ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object>DEFAULT_EXPRESSION_CACHE_VALIDITY_CHECKERDefault expression cache validity checker: nullstatic booleanDEFAULT_TEMPLATE_CACHE_ENABLE_COUNTERSDefault template cache "enable counters" flag: falsestatic intDEFAULT_TEMPLATE_CACHE_INITIAL_SIZEDefault template cache initial size: 20static java.lang.StringDEFAULT_TEMPLATE_CACHE_LOGGER_NAMEDefault template cache logger name: null (default behaviour = org.thymeleaf.TemplateEngine.cache.TEMPLATE_CACHE)static intDEFAULT_TEMPLATE_CACHE_MAX_SIZEDefault template cache maximum size: 200static java.lang.StringDEFAULT_TEMPLATE_CACHE_NAMEDefault template cache name: "TEMPLATE_CACHE"static booleanDEFAULT_TEMPLATE_CACHE_USE_SOFT_REFERENCESDefault template cache "use soft references" flag: truestatic ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel>DEFAULT_TEMPLATE_CACHE_VALIDITY_CHECKERDefault template cache validity checker: an instance ofStandardParsedTemplateEntryValidator.private booleanexpressionCacheEnableCountersprivate intexpressionCacheInitialSizeprivate java.lang.StringexpressionCacheLoggerNameprivate intexpressionCacheMaxSizeprivate java.lang.StringexpressionCacheNameprivate booleanexpressionCacheUseSoftReferencesprivate ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object>expressionCacheValidityCheckerprivate booleantemplateCacheEnableCountersprivate inttemplateCacheInitialSizeprivate java.lang.StringtemplateCacheLoggerNameprivate inttemplateCacheMaxSizeprivate java.lang.StringtemplateCacheNameprivate booleantemplateCacheUseSoftReferencesprivate ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel>templateCacheValidityChecker
-
Constructor Summary
Constructors Constructor Description StandardCacheManager()
-
Method Summary
-
Methods inherited from class org.thymeleaf.cache.AbstractCacheManager
clearAllCaches, getAllSpecificCacheNames, getExpressionCache, getSpecificCache, getTemplateCache
-
-
-
-
Field Detail
-
DEFAULT_TEMPLATE_CACHE_NAME
public static final java.lang.String DEFAULT_TEMPLATE_CACHE_NAME
Default template cache name: "TEMPLATE_CACHE"- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_CACHE_INITIAL_SIZE
public static final int DEFAULT_TEMPLATE_CACHE_INITIAL_SIZE
Default template cache initial size: 20- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_CACHE_MAX_SIZE
public static final int DEFAULT_TEMPLATE_CACHE_MAX_SIZE
Default template cache maximum size: 200- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_CACHE_ENABLE_COUNTERS
public static final boolean DEFAULT_TEMPLATE_CACHE_ENABLE_COUNTERS
Default template cache "enable counters" flag: false- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_CACHE_USE_SOFT_REFERENCES
public static final boolean DEFAULT_TEMPLATE_CACHE_USE_SOFT_REFERENCES
Default template cache "use soft references" flag: true- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_CACHE_LOGGER_NAME
public static final java.lang.String DEFAULT_TEMPLATE_CACHE_LOGGER_NAME
Default template cache logger name: null (default behaviour = org.thymeleaf.TemplateEngine.cache.TEMPLATE_CACHE)
-
DEFAULT_TEMPLATE_CACHE_VALIDITY_CHECKER
public static final ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel> DEFAULT_TEMPLATE_CACHE_VALIDITY_CHECKER
Default template cache validity checker: an instance ofStandardParsedTemplateEntryValidator.
-
DEFAULT_EXPRESSION_CACHE_NAME
public static final java.lang.String DEFAULT_EXPRESSION_CACHE_NAME
Default expression cache name: "EXPRESSION_CACHE"- See Also:
- Constant Field Values
-
DEFAULT_EXPRESSION_CACHE_INITIAL_SIZE
public static final int DEFAULT_EXPRESSION_CACHE_INITIAL_SIZE
Default expression cache initial size: 100- See Also:
- Constant Field Values
-
DEFAULT_EXPRESSION_CACHE_MAX_SIZE
public static final int DEFAULT_EXPRESSION_CACHE_MAX_SIZE
Default expression cache maximum size: 500- See Also:
- Constant Field Values
-
DEFAULT_EXPRESSION_CACHE_ENABLE_COUNTERS
public static final boolean DEFAULT_EXPRESSION_CACHE_ENABLE_COUNTERS
Default expression cache "enable counters" flag: false- See Also:
- Constant Field Values
-
DEFAULT_EXPRESSION_CACHE_USE_SOFT_REFERENCES
public static final boolean DEFAULT_EXPRESSION_CACHE_USE_SOFT_REFERENCES
Default expression cache "use soft references" flag: true- See Also:
- Constant Field Values
-
DEFAULT_EXPRESSION_CACHE_LOGGER_NAME
public static final java.lang.String DEFAULT_EXPRESSION_CACHE_LOGGER_NAME
Default expression cache logger name: null (default behaviour = org.thymeleaf.TemplateEngine.cache.EXPRESSION_CACHE)
-
DEFAULT_EXPRESSION_CACHE_VALIDITY_CHECKER
public static final ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object> DEFAULT_EXPRESSION_CACHE_VALIDITY_CHECKER
Default expression cache validity checker: null
-
templateCacheName
private java.lang.String templateCacheName
-
templateCacheInitialSize
private int templateCacheInitialSize
-
templateCacheMaxSize
private int templateCacheMaxSize
-
templateCacheEnableCounters
private boolean templateCacheEnableCounters
-
templateCacheUseSoftReferences
private boolean templateCacheUseSoftReferences
-
templateCacheLoggerName
private java.lang.String templateCacheLoggerName
-
templateCacheValidityChecker
private ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel> templateCacheValidityChecker
-
expressionCacheName
private java.lang.String expressionCacheName
-
expressionCacheInitialSize
private int expressionCacheInitialSize
-
expressionCacheMaxSize
private int expressionCacheMaxSize
-
expressionCacheEnableCounters
private boolean expressionCacheEnableCounters
-
expressionCacheUseSoftReferences
private boolean expressionCacheUseSoftReferences
-
expressionCacheLoggerName
private java.lang.String expressionCacheLoggerName
-
expressionCacheValidityChecker
private ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object> expressionCacheValidityChecker
-
-
Method Detail
-
initializeTemplateCache
protected final ICache<TemplateCacheKey,TemplateModel> initializeTemplateCache()
- Specified by:
initializeTemplateCachein classAbstractCacheManager
-
initializeExpressionCache
protected final ICache<ExpressionCacheKey,java.lang.Object> initializeExpressionCache()
- Specified by:
initializeExpressionCachein classAbstractCacheManager
-
getTemplateCacheName
public java.lang.String getTemplateCacheName()
-
getTemplateCacheUseSoftReferences
public boolean getTemplateCacheUseSoftReferences()
-
getTemplateCacheEnableCounters
private boolean getTemplateCacheEnableCounters()
-
getTemplateCacheInitialSize
public int getTemplateCacheInitialSize()
-
getTemplateCacheMaxSize
public int getTemplateCacheMaxSize()
-
getTemplateCacheLoggerName
public java.lang.String getTemplateCacheLoggerName()
-
getTemplateCacheValidityChecker
public ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel> getTemplateCacheValidityChecker()
-
getTemplateCacheLogger
public final org.slf4j.Logger getTemplateCacheLogger()
-
getExpressionCacheName
public java.lang.String getExpressionCacheName()
-
getExpressionCacheUseSoftReferences
public boolean getExpressionCacheUseSoftReferences()
-
getExpressionCacheEnableCounters
private boolean getExpressionCacheEnableCounters()
-
getExpressionCacheInitialSize
public int getExpressionCacheInitialSize()
-
getExpressionCacheMaxSize
public int getExpressionCacheMaxSize()
-
getExpressionCacheLoggerName
public java.lang.String getExpressionCacheLoggerName()
-
getExpressionCacheValidityChecker
public ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object> getExpressionCacheValidityChecker()
-
getExpressionCacheLogger
public final org.slf4j.Logger getExpressionCacheLogger()
-
setTemplateCacheName
public void setTemplateCacheName(java.lang.String templateCacheName)
-
setTemplateCacheInitialSize
public void setTemplateCacheInitialSize(int templateCacheInitialSize)
-
setTemplateCacheMaxSize
public void setTemplateCacheMaxSize(int templateCacheMaxSize)
-
setTemplateCacheUseSoftReferences
public void setTemplateCacheUseSoftReferences(boolean templateCacheUseSoftReferences)
-
setTemplateCacheLoggerName
public void setTemplateCacheLoggerName(java.lang.String templateCacheLoggerName)
-
setTemplateCacheValidityChecker
public void setTemplateCacheValidityChecker(ICacheEntryValidityChecker<TemplateCacheKey,TemplateModel> templateCacheValidityChecker)
-
setTemplateCacheEnableCounters
public void setTemplateCacheEnableCounters(boolean templateCacheEnableCounters)
-
setExpressionCacheName
public void setExpressionCacheName(java.lang.String expressionCacheName)
-
setExpressionCacheInitialSize
public void setExpressionCacheInitialSize(int expressionCacheInitialSize)
-
setExpressionCacheMaxSize
public void setExpressionCacheMaxSize(int expressionCacheMaxSize)
-
setExpressionCacheUseSoftReferences
public void setExpressionCacheUseSoftReferences(boolean expressionCacheUseSoftReferences)
-
setExpressionCacheLoggerName
public void setExpressionCacheLoggerName(java.lang.String expressionCacheLoggerName)
-
setExpressionCacheValidityChecker
public void setExpressionCacheValidityChecker(ICacheEntryValidityChecker<ExpressionCacheKey,java.lang.Object> expressionCacheValidityChecker)
-
setExpressionCacheEnableCounters
public void setExpressionCacheEnableCounters(boolean expressionCacheEnableCounters)
-
-