org.apache.cocoon.components.store.impl
Class EHDefaultStore

java.lang.Object
  extended byorg.apache.cocoon.components.store.impl.EHDefaultStore
All Implemented Interfaces:
Store

public class EHDefaultStore
extends Object
implements Store

Store implementation based on EHCache (http://ehcache.sourceforge.net/) Configure the store using the setter methods.

Setting eternal to false but not setting timeToLiveSeconds and/or timeToIdleSeconds, has the same effect as setting eternal to true.

Here is an example to clarify the purpose of the timeToLiveSeconds and timeToIdleSeconds parameters:

With these settings the entry will be removed from the cache after 24 hours. If within that 24-hour period the entry is not retrieved within 3 hours after the last retrieval, it will also be removed from the cache.

By setting timeToLiveSeconds to 0, an item can stay in the cache as long as it is retrieved within timeToIdleSeconds after the last retrieval.

By setting timeToIdleSeconds to 0, an item will stay in the cache for exactly timeToLiveSeconds.

disk-persistent Whether the disk store persists between restarts of the Virtual Machine. The default value is true.

Version:
$Id: EHDefaultStore.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from interface org.apache.excalibur.store.Store
PERSISTENT_STORE, ROLE, TRANSIENT_STORE
 
Constructor Summary
EHDefaultStore()
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 void destroy()
          Shutdown the CacheManager.
 void free()
           
 Object get(Object key)
           
 Log getLogger()
           
 void init()
          Initialize the CacheManager and created the Cache.
 Enumeration keys()
           
 void remove(Object key)
           
 void setBootstrapCacheLoader(net.sf.ehcache.bootstrap.BootstrapCacheLoader bootstrapCacheLoader)
          The BootstrapCacheLoader to use to populate the cache when it is first initialised.
 void setDirectory(String directory)
          directory Specify an alternative location of the disk store.
 void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
          diskExpiryThreadIntervalSeconds (120) - The number of seconds between runs of the disk expiry thread.
 void setDiskPersistent(boolean diskPersistent)
          disk-persistent Whether the disk store persists between restarts of the Virtual Machine.
 void setEternal(boolean eternal)
          eternal (true) - whether or not entries expire.
 void setLogger(Log l)
           
 void setMaxDiskObjects(int maxDiskObjects)
          maxDiskObjects (50000) - The maximum number of disc objects.
 void setMaxMemObjects(int maxMemObjects)
          maxMemobjects (10000) - The maximum number of in-memory objects.
 void setMemoryStoreEvictionPolicy(net.sf.ehcache.store.MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)
          memoryStoreEvictionPolicy (null) - Tone of LRU, LFU and FIFO.
 void setOverflowToDisk(boolean overflowToDisk)
          overflow-to-disk (true) - Whether to spool elements to disk after maxobjects has been exceeded.
 void setRegisteredEventListeners(net.sf.ehcache.event.RegisteredEventListeners registeredEventListeners)
          A notification service.
 void setSettings(org.apache.cocoon.configuration.Settings settings)
           
 void setStoreJanitor(StoreJanitor storeJanitor)
          Use the StoreJanitor to take care of freeing memory.
 void setTimeToIdleSeconds(long timeToIdleSeconds)
          timeToIdleSeconds (0) - the maximum time between retrievals of an entry.
 void setTimeToLiveSeconds(long timeToLiveSeconds)
          timeToLiveSeconds (0) - how long an entry may live in the cache before it is removed.
 void setUseCacheDirectory(boolean useCacheDirectory)
          use-cache-directory (false) - If true the cache-directory context entry will be used as the location of the disk store.
 void setUseWorkDirectory(boolean useWorkDirectory)
          use-work-directory (false) - If true the work-directory context entry will be used as the location of the disk store.
 int size()
           
 void store(Object key, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EHDefaultStore

public EHDefaultStore()
Method Detail

setDirectory

public void setDirectory(String directory)
  • directory Specify an alternative location of the disk store.

    Parameters:
    directory - Specify an alternative location of the disk store.

  • setDiskPersistent

    public void setDiskPersistent(boolean diskPersistent)
    disk-persistent Whether the disk store persists between restarts of the Virtual Machine. The default value is true.

    Parameters:
    diskPersistent -

    setEternal

    public void setEternal(boolean eternal)
  • eternal (true) - whether or not entries expire. When set to false the timeToLiveSeconds and timeToIdleSeconds parameters are used to determine when an item expires.
  • Parameters:
    eternal -

    setMaxMemObjects

    public void setMaxMemObjects(int maxMemObjects)
    maxMemobjects (10000) - The maximum number of in-memory objects.

    Parameters:
    maxMemObjects -

    setMaxDiskObjects

    public void setMaxDiskObjects(int maxDiskObjects)
    maxDiskObjects (50000) - The maximum number of disc objects.

    Parameters:
    maxDiskObjects -

    setOverflowToDisk

    public void setOverflowToDisk(boolean overflowToDisk)
  • overflow-to-disk (true) - Whether to spool elements to disk after maxobjects has been exceeded.
  • Parameters:
    overflowToDisk -

    setTimeToIdleSeconds

    public void setTimeToIdleSeconds(long timeToIdleSeconds)
  • timeToIdleSeconds (0) - the maximum time between retrievals of an entry. If the entry is not retrieved for this period, it is removed from the cache.
  • Parameters:
    timeToIdleSeconds -

    setTimeToLiveSeconds

    public void setTimeToLiveSeconds(long timeToLiveSeconds)
  • timeToLiveSeconds (0) - how long an entry may live in the cache before it is removed. The entry will be removed no matter how frequently it is retrieved.
  • Parameters:
    timeToLiveSeconds -

    setDiskExpiryThreadIntervalSeconds

    public void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
  • diskExpiryThreadIntervalSeconds (120) - The number of seconds between runs of the disk expiry thread.
  • Parameters:
    diskExpiryThreadIntervalSeconds -

    setMemoryStoreEvictionPolicy

    public void setMemoryStoreEvictionPolicy(net.sf.ehcache.store.MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)
  • memoryStoreEvictionPolicy (null) - Tone of LRU, LFU and FIFO. If null, it will be set to LRU.
  • Parameters:
    memoryStoreEvictionPolicy -

    setRegisteredEventListeners

    public void setRegisteredEventListeners(net.sf.ehcache.event.RegisteredEventListeners registeredEventListeners)
    A notification service. Optionally null, in which case a new one with no registered listeners will be created.

    Parameters:
    registeredEventListeners -

    setBootstrapCacheLoader

    public void setBootstrapCacheLoader(net.sf.ehcache.bootstrap.BootstrapCacheLoader bootstrapCacheLoader)
    The BootstrapCacheLoader to use to populate the cache when it is first initialised. Null if none is required.

    Parameters:
    bootstrapCacheLoader -

    setUseCacheDirectory

    public void setUseCacheDirectory(boolean useCacheDirectory)
  • use-cache-directory (false) - If true the cache-directory context entry will be used as the location of the disk store. Within the servlet environment this is set in web.xml.
  • Parameters:
    useCacheDirectory -

    setUseWorkDirectory

    public void setUseWorkDirectory(boolean useWorkDirectory)
  • use-work-directory (false) - If true the work-directory context entry will be used as the location of the disk store. Within the servlet environment this is set in web.xml.
  • Parameters:
    useWorkDirectory -

    setSettings

    public void setSettings(org.apache.cocoon.configuration.Settings settings)
    Parameters:
    settings - the settings to set

    setStoreJanitor

    public void setStoreJanitor(StoreJanitor storeJanitor)
    Use the StoreJanitor to take care of freeing memory.

    Parameters:
    storeJanitor -

    getLogger

    public Log getLogger()

    setLogger

    public void setLogger(Log l)

    init

    public void init()
              throws Exception
    Initialize the CacheManager and created the Cache.

    Throws:
    Exception

    destroy

    public void destroy()
    Shutdown the CacheManager.


    get

    public Object get(Object key)
    Specified by:
    get in interface Store
    See Also:
    Store.free()

    store

    public void store(Object key,
                      Object value)
               throws IOException
    Specified by:
    store in interface Store
    Throws:
    IOException
    See Also:
    Store.free()

    free

    public void free()
    Specified by:
    free in interface Store
    See Also:
    Store.free()

    remove

    public void remove(Object key)
    Specified by:
    remove in interface Store
    See Also:
    Store.remove(java.lang.Object)

    clear

    public void clear()
    Specified by:
    clear in interface Store
    See Also:
    Store.clear()

    containsKey

    public boolean containsKey(Object key)
    Specified by:
    containsKey in interface Store
    See Also:
    Store.containsKey(java.lang.Object)

    keys

    public Enumeration keys()
    Specified by:
    keys in interface Store
    See Also:
    Store.keys()

    size

    public int size()
    Specified by:
    size in interface Store
    See Also:
    Store.size()


    Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.