Cache implementation.

Package Specification

Purpose

Two kinds of caches are supported: memory caches and persistent caches. Persistent caches store their content in a filessystem.
Cache templates are supported, which can be used to define default cache configurations.

Installation

In the cache.properties file:

Specify the list of preconfigured caches:
PropertyRequiredDescription
cache.caches
yes The List of preconfigured cache names
Specify the list of cache templates:
PropertyRequiredDescription
cache.templates
no The List of cache templates (template names must be distinct from all cache names)

Example:

cache.templates = simpletempl
cache.caches = memcache,perscache
Definition of  a cache template:

A cache template may contain all the properties that are for suitable for a cache. When a cache uses a template, all the properties of the template are added to the cache properties. Cache properties always override template properties.

Example:

template.simpletempl.type = memory
template.simpletempl.class = com.sapportals.wcm.util.cache.memory.MemoryLRUCache
template.simpletempl.capacity = 1000
template.simpletempl.maxsize = 0
template.simpletempl.maxentrysize = 0
template.simpletempl.defaulttimetolive = 300
template.simpletempl.averageentrysize = 0
template.simpletempl.singleton = true
Configuration of  a memory cache:
PropertyRequiredDescription
type
yes The type of the cache (memory or persistent)
class
yes The Java class implementing the cache, com.sapportals.wcm.util.cache.memory.MemoryLRUCache
capacity
yes The capacity of the cache (i.e. the max. number of cache entries)
maxsize
yes The max. value for the sum of the size of all cache entries in bytes (0 means no limit)
maxentrysize
yes The max. size of a cache entry in bytes (0 means no limit)
defaulttimetolive
yes The default time in seconds after which a cache entry is removed from the cache automatically (0 means no expiration)
averageentrysize
yes The size in bytes a new cache entry is assumed to have if no other size is specified
singleton
yes The instantiation type of the cache (true for singleton, false otherwise)

Example (using no template):

cache.memcache.type = memory
cache.memcache.class = com.sapportals.wcm.util.cache.memory.MemoryLRUCache
cache.memcache.capacity = 1000
cache.memcache.maxsize = 1000000
cache.memcache.maxentrysize = 1000
cache.memcache.defaulttimetolive = 300
cache.memcache.averageentrysize = 1000
cache.memcache.singleton = true

Example (using a template):

cache.memcache.template = simpletempl
cache.memcache.capacity = 512
Configuration of  a persistent  cache:
PropertyRequiredDescription
type
yes The type of the cache (memory or persistent)
class
yes The Java class implementing the cache, com.sapportals.wcm.util.cache.persistent.PersistentLRUCache
capacity
yes The capacity of the cache (i.e. the max. number of cache entries)
maxsize
yes The max. value for the sum of the size of all cache entries in bytes (0 means no limit)
maxentrysize
yes The max. size of a cache entry in bytes (0 means no limit)
defaulttimetolive
yes The default time in seconds after which a cache entry is removed from the cache automatically (0 means no expiration)
storageclass
yes The Java class implementing the persistent cache map, com.sapportals.wcm.util.cache.persistent.filesystem.FilesystemMap
folder
yes The folder in which the cache files are stored (must exist already)
fileprefix
yes The prefix which is preceded the names of the cache files
secure
yes The desired security type of the cache (true for encrypted cache, false otherwise)
clearcacheoninit
yes The desired initialization type of the cache (true if the cache is cleared during initialization, false otherwise)

Example:

cache.perscache.type = persistent
cache.perscache.class = com.sapportals.wcm.util.cache.persistent.PersistentLRUCache
cache.perscache.capacity = 1000
cache.perscache.maxsize = 50000000
cache.perscache.maxentrysize = 10000
cache.perscache.defaulttimetolive = 600
cache.perscache.storageclass = com.sapportals.wcm.util.cache.persistent.filesystem.FilesystemMap
cache.perscache.folder = /temp
cache.perscache.fileprefix = perscache_
cache.perscache.secure = true
cache.perscache.clearcacheoninit = true

Implementation notes

Issues

Related Documentation