freemarker.template.cache
Class NullCachingStrategy

java.lang.Object
  extended by freemarker.template.cache.BaseCachingStrategy
      extended by freemarker.template.cache.NullCachingStrategy
All Implemented Interfaces:
Cache, CachingStrategy, Updateable

public final class NullCachingStrategy
extends BaseCachingStrategy

Implements the most simple caching strategy possible: a null cache. That is, no caching takes place at all, the strategy simply forwards all requests onto the cache retriever.

Version:
$Id: NullCachingStrategy.java 1153 2013-04-15 10:59:37Z run2000 $
Author:
Nicholas Cull

Field Summary
 
Fields inherited from class freemarker.template.cache.BaseCachingStrategy
eventHandler, retriever
 
Constructor Summary
NullCachingStrategy()
          Creates new NullCachingStrategy.
NullCachingStrategy(CacheRetriever retriever)
          Creates new NullCachingStrategy with a cache retriever.
NullCachingStrategy(StrategyParameters params)
          Creates new NullCachingStrategy with the given parameters.
 
Method Summary
 void clearCache()
          Clears all the elements in the cache.
 java.lang.String getDefaultTemplateType()
          Retrieves the default template type to be created when retrieving items from the cache.
 long getDelay()
          Returns the interval between two cache updates.
 Cacheable getItem(java.lang.String name)
          Retrieves an item from the cache, according to the loading policy implemented.
 Cacheable getItem(java.lang.String name, java.lang.String type)
          Retrieves an item from the cache, according to the loading policy implemented.
 int getMaximumAge()
          Retrieves the maximum age a cache item can be before it is evicted from the cache.
 java.util.Iterator<CacheElement> listCachedFiles()
          Retrieves a list of objects currently in the cache.
 void startAutoUpdate()
          Begins automatic updates of the cache.
 void stopAutoUpdate()
          Stops automatically updating the cache.
 java.lang.String toString()
          Returns a string representation of the object.
 void update()
          Asks for a "blank" update.
 void update(java.lang.String name)
          Asks for the named object to be updated.
 void update(java.lang.String name, java.lang.String type)
          Asks for the named object to be updated.
 
Methods inherited from class freemarker.template.cache.BaseCachingStrategy
addCacheListener, connectionOk, getCacheListeners, getCacheRetriever, removeCacheListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NullCachingStrategy

public NullCachingStrategy()
Creates new NullCachingStrategy.


NullCachingStrategy

public NullCachingStrategy(StrategyParameters params)
Creates new NullCachingStrategy with the given parameters.

Parameters:
params - the parameters with which to initialize this strategy

NullCachingStrategy

public NullCachingStrategy(CacheRetriever retriever)
Creates new NullCachingStrategy with a cache retriever.

Parameters:
retriever - the retriever to use to pull items from the data store
Method Detail

getDelay

public long getDelay()
Returns the interval between two cache updates. This is meaningful only if the cache policy is a load-on-demand or preload type.

Returns:
the number of seconds between cache updates

getMaximumAge

public int getMaximumAge()
Retrieves the maximum age a cache item can be before it is evicted from the cache. The age is determined as the number of cache updates since the item was last accessed. This is meaningful only if the cache policy is a load-on-demand type.

Returns:
the maximum age before an item is evicted from the cache

getDefaultTemplateType

public java.lang.String getDefaultTemplateType()
Retrieves the default template type to be created when retrieving items from the cache.

Returns:
the type of template cached by default

getItem

public Cacheable getItem(java.lang.String name)
Retrieves an item from the cache, according to the loading policy implemented.

Parameters:
name - the name of the item to retrieve
Returns:
the corresponding Cacheable object, or null if not found or an error has occurred

getItem

public Cacheable getItem(java.lang.String name,
                         java.lang.String type)
Retrieves an item from the cache, according to the loading policy implemented.

Parameters:
name - the name of the item to retrieve
type - the type of the item to retrieve
Returns:
the corresponding Cacheable object, or null if not found or an error has occurred

listCachedFiles

public java.util.Iterator<CacheElement> listCachedFiles()
Retrieves a list of objects currently in the cache.

Returns:
null, indicating that no caching is used

update

public void update()
Asks for a "blank" update. It is up to the implementation to determine what has to be updated.


update

public void update(java.lang.String name)
Asks for the named object to be updated.

Parameters:
name - the name of the object to update

update

public void update(java.lang.String name,
                   java.lang.String type)
Asks for the named object to be updated.

Parameters:
name - the name of the object to update
type - the type of the object to update

startAutoUpdate

public void startAutoUpdate()
Begins automatic updates of the cache.


stopAutoUpdate

public void stopAutoUpdate()
Stops automatically updating the cache.


clearCache

public void clearCache()
Clears all the elements in the cache.


toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the object