freemarker.template.cache
Interface Cache

All Known Subinterfaces:
CachingStrategy, TemplateCache
All Known Implementing Classes:
BaseCachingStrategy, FileTemplateCache, LoadAdHocCachingStrategy, LoadOnDemandCachingStrategy, LoDWithRefreshCachingStrategy, NullCachingStrategy, PreloadCachingStrategy

public interface Cache

An interface for self-updating caches consisting of any single type of object. The class of objects to be held in the cache is not specified by this interface.

Version:
$Id: Cache.java 1101 2013-04-01 04:17:32Z run2000 $
See Also:
Updateable

Method Summary
 void addCacheListener(CacheListener listener)
          Registers a CacheListener for this Cache.
 CacheListener[] getCacheListeners()
          Retrieves all the listeners associated with this Cache.
 Cacheable getItem(java.lang.String name)
          Gets an item from the cache.
 Cacheable getItem(java.lang.String name, java.lang.String type)
          Gets an item of the specified type from the cache.
 java.util.Iterator<CacheElement> listCachedFiles()
          Returns an iterator over a list of CacheElement instances.
 void removeCacheListener(CacheListener listener)
          Unregisters a CacheListener for this Cache.
 void stopAutoUpdate()
          Stops automatically updating the cache.
 

Method Detail

addCacheListener

void addCacheListener(CacheListener listener)
Registers a CacheListener for this Cache.

Parameters:
listener - the CacheListener to be registered.

removeCacheListener

void removeCacheListener(CacheListener listener)
Unregisters a CacheListener for this Cache.

Parameters:
listener - the CacheListener to be unregistered.

getCacheListeners

CacheListener[] getCacheListeners()
Retrieves all the listeners associated with this Cache.

Returns:
an array of CacheListeners

stopAutoUpdate

void stopAutoUpdate()
Stops automatically updating the cache. Normally only call this prior to cache shutdown.


listCachedFiles

java.util.Iterator<CacheElement> listCachedFiles()
Returns an iterator over a list of CacheElement instances.

Returns:
the iterator over a list of CacheElement instances that correspond to templates in the cache

getItem

Cacheable getItem(java.lang.String name)
Gets an item from the cache. Assumes a default type of object will be returned.

Parameters:
name - a string uniquely identifying the item.
Returns:
the item corresponding to the name, or null if not found.

getItem

Cacheable getItem(java.lang.String name,
                  java.lang.String type)
Gets an item of the specified type from the cache.

Parameters:
name - a string uniquely identifying the item.
type - the type of item to be retrieved
Returns:
the item corresponding to the name, or null if not found.