org.thymeleaf.templateresolver
Class TTLTemplateResolutionValidity

Object
  extended by org.thymeleaf.templateresolver.TTLTemplateResolutionValidity
All Implemented Interfaces:
ITemplateResolutionValidity

public class TTLTemplateResolutionValidity
extends Object
implements ITemplateResolutionValidity

Simple implementation of ITemplateResolutionValidity that 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
TTLTemplateResolutionValidity(long cacheTTLMs)
           Creates a new instance of this validity implementation.
 
Method Summary
 long getCacheTTLMs()
           Returns the TTL in milliseconds to be applied to template validity.
 boolean isCacheable()
           Returns true.
 boolean isCacheStillValid()
           Returns whether the template resolution can still be considered valid.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TTLTemplateResolutionValidity

public TTLTemplateResolutionValidity(long cacheTTLMs)

Creates a new instance of this validity implementation.

Parameters:
cacheTTLMs - the TTL to be applied to the template resolution.
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:
isCacheable in interface ITemplateResolutionValidity
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:
isCacheStillValid in interface ITemplateResolutionValidity
Returns:
whether the (cached) template resolution can still be considered valid.


Copyright © 2012 The THYMELEAF team. All Rights Reserved.