org.webmacro.resource
Class GenerationalCacheManager

java.lang.Object
  extended byorg.webmacro.resource.GenerationalCacheManager
All Implemented Interfaces:
CacheManager

public class GenerationalCacheManager
extends java.lang.Object
implements CacheManager

An implementation of CacheManager which uses the "VFC" cache manager from Acctiva and Open Doors Software.

This manager provides a number of specific property options to support flexible deployment. Understanding these options is useful if you want behavior to adapt from development to deployment.

The default behavior, for the most part, is optimized for production deployment. Therefore, you must explicitly set some options to gain certain kinds of caching behavior appropriate for a development setting, eg, reloadability of a file which has changed on disk.

This cache manager supports reloadability of a cache entry provided the cache element knows how to test itself for having become stale.

The GenerationalCacheManager implements the CacheManager interface for WebMacro providers which extend the CachingProvider base class. This implementation encapsulates the use of VFC provided by Open Doors Software and incorporated into WM.

Since:
0.96
Author:
Lane Sharman (lane@opendoors.com)

Constructor Summary
GenerationalCacheManager()
           
 
Method Summary
 void destroy()
          Same as defined in Provider
 void flush()
          Same as defined in Provider
 java.lang.Object get(java.lang.Object query)
          Get the object associated with the specific query, trying to look it up in a cache.
 java.lang.Object get(java.lang.Object query, ResourceLoader helper)
          Get the cached value and load it if it is not present or reloading is required.
 long[] getMetrics()
          Returns cache instrumentation statistics.
 java.lang.String getResourceType()
          Returns the wm type of resource it is caching.
 void init(Broker b, Settings config, java.lang.String resourceType)
          Same as defined in Provider, except with an additional type parameter so it knows what type of resource it is caching
 void invalidate(java.lang.Object query)
          Invalidate an entry in the cache.
 void put(java.lang.Object query, java.lang.Object resource)
          Put an object in the cache
 boolean supportsReload()
          This manager supports reloading and so this returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenerationalCacheManager

public GenerationalCacheManager()
Method Detail

init

public void init(Broker b,
                 Settings config,
                 java.lang.String resourceType)
          throws InitException
Description copied from interface: CacheManager
Same as defined in Provider, except with an additional type parameter so it knows what type of resource it is caching

Specified by:
init in interface CacheManager
Throws:
InitException

flush

public void flush()
Description copied from interface: CacheManager
Same as defined in Provider

Specified by:
flush in interface CacheManager

destroy

public void destroy()
Description copied from interface: CacheManager
Same as defined in Provider

Specified by:
destroy in interface CacheManager

get

public java.lang.Object get(java.lang.Object query,
                            ResourceLoader helper)
                     throws ResourceException
Get the cached value and load it if it is not present or reloading is required.

Specified by:
get in interface CacheManager
Throws:
ResourceException

get

public java.lang.Object get(java.lang.Object query)
Get the object associated with the specific query, trying to look it up in a cache. If it's not there, return null.

Specified by:
get in interface CacheManager

put

public void put(java.lang.Object query,
                java.lang.Object resource)
Put an object in the cache

Specified by:
put in interface CacheManager

invalidate

public void invalidate(java.lang.Object query)
Invalidate an entry in the cache.

Specified by:
invalidate in interface CacheManager

supportsReload

public boolean supportsReload()
This manager supports reloading and so this returns true.

Specified by:
supportsReload in interface CacheManager

getResourceType

public java.lang.String getResourceType()
Returns the wm type of resource it is caching.


getMetrics

public long[] getMetrics()
Returns cache instrumentation statistics.

These statistics will be zero if the cache implementation is not using the instrumented get() routine.

Use of this routine is normally reserved for performance analysis and depends on recompiling org.opendoors.cache.immutable.CacheImpl

Returns:
an array of longs with the following def.
 [0] The total number of gets, accesses.
 [1] The number of accesses which resulted in a hit to the immutable cache.
 [2] The number of accesses which resulted in a hit to the mutable cache.
 [3] The number of accesses which resulted in a fault and a need to
 regenerate the cache entry.
 
See Also:
org.opendoors.cache.impl.CacheImpl