|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.oscache.base.AbstractCacheAdministrator
An AbstractCacheAdministrator defines an abstract cache administrator, implementing all the basic operations related to the configuration of a cache, including assigning any configured event handlers to cache objects.
Extend this class to implement a custom cache administrator.
Field Summary | |
protected String |
algorithmClass
The algorithm class being used, as specified by the CACHE_ALGORITHM_KEY
configuration property. |
static String |
CACHE_ALGORITHM_KEY
A String cache configuration property that specifies the classname of an alternate caching algorithm. |
static String |
CACHE_BLOCKING_KEY
The configuration key that specifies whether we should block waiting for new content to be generated, or just serve the old content instead. |
static String |
CACHE_CAPACITY_KEY
An integer cache configuration property that specifies the maximum number of objects to hold in the cache. |
static String |
CACHE_DISK_UNLIMITED_KEY
A boolean cache configuration property that indicates whether the persistent cache should be unlimited in size, or should be restricted to the same size as the in-memory cache. |
static String |
CACHE_ENTRY_EVENT_LISTENERS_KEY
A String cache configuration property that holds a comma-delimited list of classnames. |
static String |
CACHE_MEMORY_KEY
A boolean cache configuration property that indicates whether the cache should cache objects in memory. |
static String |
CACHE_PERSISTENCE_OVERFLOW_KEY
A String cache configuration property that specifies if the cache persistence will only be used in overflow mode, that is, when the memory cache capacity has been reached. |
protected int |
cacheCapacity
The cache capacity (number of entries), as specified by the CACHE_CAPACITY_KEY
configuration property. |
protected Config |
config
|
protected EventListenerList |
listenerList
Holds a list of all the registered event listeners. |
static String |
PERSISTENCE_CLASS_KEY
A String cache configuration property that specifies the classname that will be used to provide cache persistence. |
Constructor Summary | |
protected |
AbstractCacheAdministrator()
Create the AbstractCacheAdministrator. |
protected |
AbstractCacheAdministrator(Properties p)
Create the AbstractCacheAdministrator. |
Method Summary | |
protected Cache |
configureStandardListeners(Cache cache)
Applies all of the recognised listener classes to the supplied cache object. |
protected void |
finalizeListeners(Cache cache)
Finalizes all the listeners that are associated with the given cache object. |
protected CacheEventListener[] |
getCacheEventListeners()
Retrieves an array containing instances all of the CacheEventListener
classes that are specified in the OSCache configuration file. |
String |
getProperty(String key)
Retrieves the value of one of the configuration properties. |
boolean |
isBlocking()
Indicates whether the cache will block waiting for new content to be built, or serve stale content instead of waiting. |
boolean |
isMemoryCaching()
Whether entries are cached in memory or not. |
boolean |
isOverflowPersistence()
Check if we use overflowPersistence |
boolean |
isUnlimitedDiskCache()
Indicates whether the unlimited disk cache is enabled or not. |
void |
setAlgorithmClass(String newAlgorithmClass)
Sets the algorithm to use for the cache. |
protected void |
setCacheCapacity(int newCacheCapacity)
Sets the cache capacity (number of items). |
void |
setOverflowPersistence(boolean overflowPersistence)
Sets the overflowPersistence flag |
protected Cache |
setPersistenceListener(Cache cache)
If there is a PersistenceListener in the configuration
it will be instantiated and applied to the given cache object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String CACHE_MEMORY_KEY
false
to disable in-memory caching.
public static final String CACHE_CAPACITY_KEY
public static final String CACHE_ALGORITHM_KEY
AbstractConcurrentReadCache
By default caches will use LRUCache
as
the default algorithm if the cache capacity is set to a postive value, or
UnlimitedCache
if the
capacity is negative (ie, disabled).
public static final String CACHE_DISK_UNLIMITED_KEY
true
to allow the
persistent cache to grow without bound.
public static final String CACHE_BLOCKING_KEY
public static final String PERSISTENCE_CLASS_KEY
PersistenceListener
.
public static final String CACHE_PERSISTENCE_OVERFLOW_KEY
public static final String CACHE_ENTRY_EVENT_LISTENERS_KEY
protected Config config
protected EventListenerList listenerList
CACHE_ENTRY_EVENT_LISTENERS_KEY
configuration key.
protected String algorithmClass
CACHE_ALGORITHM_KEY
configuration property.
protected int cacheCapacity
CACHE_CAPACITY_KEY
configuration property.
Constructor Detail |
protected AbstractCacheAdministrator()
protected AbstractCacheAdministrator(Properties p)
p
- the configuration properties for this cache.Method Detail |
public void setAlgorithmClass(String newAlgorithmClass)
newAlgorithmClass
- The class to use (eg.
"com.opensymphony.oscache.base.algorithm.LRUCache"
)LRUCache
,
FIFOCache
,
UnlimitedCache
public boolean isBlocking()
protected void setCacheCapacity(int newCacheCapacity)
Cache
objects
are updated correctly (by calling AbstractConcurrentReadCache.setMaxEntries(int)
}}.
newCacheCapacity
- The new capacitypublic boolean isMemoryCaching()
cache.memory
property.
public String getProperty(String key)
key
- The key assigned to the property
null
if the property could not be found.public boolean isUnlimitedDiskCache()
public boolean isOverflowPersistence()
public void setOverflowPersistence(boolean overflowPersistence)
overflowPersistence
- The overflowPersistence to set.protected CacheEventListener[] getCacheEventListeners()
CacheEventListener
classes that are specified in the OSCache configuration file.
protected Cache setPersistenceListener(Cache cache)
PersistenceListener
in the configuration
it will be instantiated and applied to the given cache object. If the
PersistenceListener
cannot be found or instantiated, an
error will be logged but the cache will not have a persistence listener
applied to it and no exception will be thrown.
A cache can only have one PersistenceListener
.
cache
- the cache to apply the PersistenceListener
to.
protected Cache configureStandardListeners(Cache cache)
CacheEntryEventListener
and CacheMapAccessEventListener
.
cache
- The cache to apply the configuration to.
protected void finalizeListeners(Cache cache)
FinalizationException
s that are thrown by the listeners will
be caught and logged.
|
OSCache Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |