Package org.thymeleaf.cache
Class TTLCacheEntryValidity
- Object
-
- org.thymeleaf.cache.TTLCacheEntryValidity
-
- All Implemented Interfaces:
ICacheEntryValidity
public class TTLCacheEntryValidity extends Object implements ICacheEntryValidity
Simple implementation of
ICacheEntryValiditythat uses a TTL (time-to-live) expressed in milliseconds to compute the validity of template cache entries.- Since:
- 1.0
- Author:
- Daniel Fernández
-
-
Constructor Summary
Constructors Constructor Description TTLCacheEntryValidity(long cacheTTLMs)Creates a new instance of this validity implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCacheTTLMs()Returns the TTL in milliseconds to be applied to template validity.booleanisCacheable()Returns true.booleanisCacheStillValid()Returns whether the template resolution can still be considered valid.
-
-
-
Method Detail
-
getCacheTTLMs
public long getCacheTTLMs()
Returns the TTL in milliseconds to be applied to template validity.
- Returns:
- the TTL in milliseconds
-
isCacheable
public boolean isCacheable()
Returns true. Templates are always considered cacheable using this validity implementation.
- Specified by:
isCacheablein interfaceICacheEntryValidity- Returns:
- true
-
isCacheStillValid
public boolean isCacheStillValid()
Returns whether the template resolution can still be considered valid. This is done by computing the difference in milliseconds between the moment when this object was created and the moment this method is called, and checking it is less than the established TTL (time-to-live).
- Specified by:
isCacheStillValidin interfaceICacheEntryValidity- Returns:
- whether the (cached) template resolution can still be considered valid.
-
-