freemarker.template.cache
Interface CachingStrategy

All Superinterfaces:
Cache, Updateable
All Known Implementing Classes:
BaseCachingStrategy

public interface CachingStrategy
extends Updateable, Cache

Abstract interface for a cache loading strategy. Items may be loaded and cached based on a variety of algorithms. This interface abstracts out the loading policy from the rest of the caching machinery.

Version:
$Id: CachingStrategy.java,v 1.10 2003/11/08 07:54:35 run2000 Exp $
Author:
Nicholas Cull
See Also:
Updateable

Method Summary
 void clearCache()
          Clears all the elements in the cache.
 CacheRetriever getCacheRetriever()
          Retrieve the CacheRetriever currently being used.
 long getDelay()
          Returns the interval between two cache updates.
 int getMaximumAge()
          Retrieves the maximum age a cache item can be before it is evicted from the cache.
 void setCacheRetriever(CacheRetriever retriever)
          Sets the CacheRetriever for this caching strategy.
 void setDefaultTemplate(java.lang.String template)
          Sets the default template to use when retrieving.
 void setDelay(long delay)
          Sets the interval between two cache updates.
 void setEventHandler(CacheEventAdapter handler)
          Sets the object to be used for firing cache events.
 void setMaximumAge(int age)
          Sets the maximum age a cache item can be before it is evicted from the cache.
 void startAutoUpdate()
          Begins automatic updates of the cache.
 
Methods inherited from interface freemarker.template.cache.Updateable
update, update, update
 
Methods inherited from interface freemarker.template.cache.Cache
addCacheListener, getCacheListeners, getItem, getItem, listCachedFiles, removeCacheListener, stopAutoUpdate
 

Method Detail

setCacheRetriever

public void setCacheRetriever(CacheRetriever retriever)
Sets the CacheRetriever for this caching strategy.
Parameters:
retriever - the CacheRetriever to be used

getCacheRetriever

public CacheRetriever getCacheRetriever()
Retrieve the CacheRetriever currently being used.
Returns:
the current CacheRetriever

setDelay

public void setDelay(long delay)
Sets the interval between two cache updates. This is meaningful only if the cache policy is a load-on-demand or preload type.
Parameters:
delay - the number of seconds between cache updates

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

setMaximumAge

public void setMaximumAge(int age)
Sets 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.
Parameters:
age - the maximum age before an item is evicted from the cache

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

clearCache

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

setEventHandler

public void setEventHandler(CacheEventAdapter handler)
Sets the object to be used for firing cache events.
Parameters:
handler - the event handler to use for firing events

setDefaultTemplate

public void setDefaultTemplate(java.lang.String template)
Sets the default template to use when retrieving.
Parameters:
template - the type of template to be used by default when retrieving objects from the repository

startAutoUpdate

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