This guide only covers the configuration of OSCache by using the `oscache.properties` file. To see how to install OSCache and where to place the `oscache.properties` file, see the Installation Guide.

The following properties are able to be set in the `oscache.properties` file:

### cache.memory

Valid values are `true` or `false`, with `true` being the default value. If you want to disable memory caching, just comment out or remove this line.

Note: disabling memory AND disk caching is possible but fairly stupid ;)

### cache.capacity

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.

### cache.algorithm

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 `com.opensymphony.oscache.base.algorithm.LRUCache`.

OSCache currently comes with three algorithms:

- `com.opensymphony.oscache.base.algorithm.LRUCache` - Least Recently Used. This is the default when a `cache.capacity` is set.
- `com.opensymphony.oscache.base.algorithm.FIFOCache` - First In First Out.
- `com.opensymphony.oscache.base.algorithm.UnlimitedCache` - Content that is added to the cache will never be discarded. This is the default when no value is set for the `cache.capacity` property.

### cache.unlimited.disk

Indicates whether the disk cache should be treated as unlimited or not. The default value is `false`.

### cache.persistence.class

Specifies the class to use for persisting cache entries. This class must implement the `PersistenceListener` interface. OSCache comes with an implementation that provides filesystem based persistence. Set this property to `com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener` to enable this implementation. By specifying your own class here you should be able to persist cache data using say JDBC or LDAP.

The `DiskPersistenceListener` class requires the following extra configuration property to be set:

> ### cache.path

> 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.

> Note: for Windows machines, the backslash character '\' needs to be escaped. ie in Windows:

> `cache.path=c:\\myapp\\cache`

> or *ix:

> `cache.path=/opt/myapp/cache`

### cache.event.listeners

This takes a comma-delimited list of fully-qualified class names. Each class in the list must implement one (or more) of the following interfaces:

- CacheEntryEventListener - Receives cache add/update/flush and remove events.
- CacheMapAccessEventListener - Receives cache access events. This allows you to keep statistical information to track how effectively the cache is working.

No listeners are configured by default, however some ship with OSCache that you may wish to enable:

- com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener - 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 Clustering OSCache for further information about this event listener.
- com.opensymphony.oscache.extra.CacheEntryEventListenerImpl - a simple listener implementation that maintains a running count of all of the entry events that occur during a cache's lifetime.
- com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl - 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 instance.

It is also of course quite straightforward to write your own event listener. See the JavaDoc API for further details.

### cache.key

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 `"__oscache_cache"`. If you want to access this default value in your code, it is available as `com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY`.

### cache.use.host.domain.in.key

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 `true`. The default value is `false`.

### Additional Properties

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 `JavaGroupsBroadcastingListener` supports the following additional properties:

cache.cluster.multicast.ip

The multicast IP to use for this cache cluster. Defaults to `231.12.21.132`.

cache.cluster.properties

Specifies additional configuration options for the clustering. The default setting is

`UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;mcast_send_buf_size=150000;mcast_recv_buf_size=80000):PING(timeout=2000;num_initial_members=3):MERGE2(min_interval=5000;max_interval=10000):FD_SOCK:VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):pbcast.STABLE(desired_avg_gossip=20000):UNICAST(timeout=5000):FRAG(frag_size=8096;down_thread=false;up_thread=false):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)`

See the Clustering OSCache documentation for further details on the above two properties.