freemarker.template.cache
Interface CachingStrategy

All Superinterfaces:
Cache, Updateable
All Known Implementing Classes:
BaseCachingStrategy, LoadAdHocCachingStrategy, LoadOnDemandCachingStrategy, LoDWithRefreshCachingStrategy, NullCachingStrategy, PreloadCachingStrategy

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 1003 2004-10-16 14:54:58Z run2000 $
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

void setCacheRetriever(CacheRetriever retriever)
Sets the CacheRetriever for this caching strategy.

Parameters:
retriever - the CacheRetriever to be used

getCacheRetriever

CacheRetriever getCacheRetriever()
Retrieve the CacheRetriever currently being used.

Returns:
the current CacheRetriever

setDelay

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

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

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

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

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


setEventHandler

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

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

void startAutoUpdate()
Begins automatic updates of the cache.