oscache / docs / configuration.html

<title>OSCache Configuration Guide</title>
<body bgcolor="#FFFFFF">
<p>This guide only covers the configuration of OSCache by using the <code></code> file.
  To see how to install OSCache and where to place the <code></code> file, see the
  <a href="install.html">Installation Guide</a>.</p>

The following properties are able to be set in the <code></code> file:

<p>Valid values are <code>true</code> or <code>false</code>, with <code>true</code> being the default value.
If you want to disable memory caching, just comment out or remove this line.</p>
<p>Note: disabling memory AND disk caching is possible but fairly stupid ;)</p>

<p>The maximum number of items that a cache will hold. By default the capacity is unlimited - the cache will
never remove any items. Negative values will also be treated as meaning unlimited capacity.</p>

<p>The default cache algorithm to use. Note that in order to use an algorithm the cache size must also
be specified. If the cache size is not specified, the cache algorithm will be Unlimited cache regardless
of the value of this property. If you specify a size but not an algorithm, the cache algorithm used will be
<p>OSCache currently comes with three algorithms:
  <li><code>com.opensymphony.oscache.base.algorithm.LRUCache</code> - Least Recently Used. This is the
  default when a <code>cache.capacity</code> is set.</li>
  <li><code>com.opensymphony.oscache.base.algorithm.FIFOCache</code> - First In First Out.</li>
  <li><code>com.opensymphony.oscache.base.algorithm.UnlimitedCache</code> - Content that is added to
  the cache will never be discarded. This is the default when no value is set for the <code>cache.capacity</code>

<p>Indicates whether the disk cache should be treated as unlimited or not. The default value is

<p>Specifies the class to use for persisting cache entries. This class must implement the <code>PersistenceListener</code>
interface. OSCache comes with an implementation that provides filesystem based persistence. Set this property
to <code>com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener</code> to enable this
implementation. By specifying your own class here you should be able to persist cache data using say JDBC or LDAP.</p>
<p>The <code>DiskPersistenceListener</code> class requires the following extra configuration property to be
<p>This specifies the directory on disk where caches will be stored. The directory will be created if it
doesn't already exist, but remember that OSCache must have permission to write to this location.</p>
<p>Note: for Windows machines, the backslash character '\' needs to be escaped. ie in Windows:</p>
<p>or *ix:</p>

<p>This takes a comma-delimited list of fully-qualified class names. Each class in the list <em>must</em>
implement one (or more) of the following interfaces:
  <li><b>CacheEntryEventListener</b> - Receives cache add/update/flush and remove events.</li>
  <li><b>CacheMapAccessEventListener</b> - Receives cache access events. This allows you to keep statistical
  information to track how effectively the cache is working.</li>
No listeners are configured by default, however some ship with OSCache that you may wish to enable:
    - provides clustering support for OSCache. Enabling this will cause cache flush events to be broadcast to
    other instances of OSCache running on your LAN. See <a href="clustering.html">Clustering OSCache</a> for
    further information about this event listener.</li>
  <li><b>com.opensymphony.oscache.extra.CacheEntryEventListenerImpl</b> - a simple listener implementation
    that maintains a running count of all of the entry events that occur during a cache's lifetime.</li>
  <li><b>com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl</b> - a simple listener implementation
    that keeps count of all the cache map events (cache hits and misses, and stale hits) that occur on a cache
It is also of course quite straightforward to write your own event listener. See the
<a href="api">JavaDoc API</a> for further details.</p>

<p>This is the key that will be used by the ServletCacheAdministrator (and hence the custom tags) to
store the cache object in the application and session scope. The default value when this property is
not specified is <code>"__oscache_cache"</code>. If you want to access this default value in your code,
it is available as <code>com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY</code>.</p>

<p>If your server is configured with multiple hosts, you may wish to add host name information to
automatically generated cache keys. If so, set this property to <code>true</code>. The default value
is <code>false</code>.</p>

<h3>Additional Properties</h3>

<p>In additon to the above basic options, any other properties that are specified in this file will still be
loaded and can be made available to your event handlers. For example, the <code>JavaGroupsBroadcastingListener</code>
supports the following additional properties:</p>

<p>The multicast IP to use for this cache cluster. Defaults to <code></code>.

<p>Specifies additional configuration options for the clustering. The default setting is</p>

<p>See the <a href="clustering.html">Clustering OSCache</a> documentation for further details on the above
two properties.</p>