This class provides an access point for pluggable caching mechanisms. Right
now, it only supports the caching mechanisms implemented in
org.hibernate.cache .
To use the cache manager, you need to include the following information in
your pentaho.xml .
<cache-provider>
<class>org.hibernate.cache.xxxxxxxx</class>
<region>pentahoCache</region>
<properties>
<property name="someProperty">someValue</property>
</properties>
</cache-provider>
The specified class must implement the
org.hibernate.cache.CacheProvider interface.
Each implementation of the org.hibernate.cache.CacheProvider
has slightly different requirements with respect to the required input
parameters - so, please see the classes in that package for more information
(available from the Sourceforge Hibernate project). Also, some cache
providers (notably the org.hibernate.cache.EhCacheProvider )
completely ignore the passed in properties, and only configure themselves by
locating a configuration file (e.g. ehcache.xml) on the classpath.
The cache manager supports session-based caching (that is, caching of data
that is user-specific) as well as global-based caching (that is, caching of
data that is system-wide). To differentiate between session-based and
global-based caching, there are different methods that get called depending
upon the storage type.
Data that is cached for user sessions require an IPentahoSession
object to be passed in. The cache manager uses the
IPentahoSession.getId() to classify saved objects underneath a
specific user session. No information is actually stored in the user session
object. For an example of this, see
putInSessionCache(IPentahoSession session, String key, Object value)
Data that is server-wide (i.e. global) uses different methods for
storage/retrieval/management. For an example of this, see
getFromGlobalCache(Object key)
Example Usage:
String globalCachable = "String to cache";
String globalCacheKey = "StringKey";
CacheManager cacheManager = PentahoSystem.getCacheManager();
cacheManager.putInGlobalCache(globalCacheKey, globalCachable);
Important Considerations
- Most caches require objects that go into the cache as well as their
respective object key implement Serializable. It is a safe assumption
that both the Key and the Value should implement Serializable.
- Some caches are read-only. Other caches are read-write. What does this
mean? It means that once you put an object in the cache, you can't put an
object into the cache with the same key. You'd need to remove it first
See Also: org.hibernate.cache.CacheProvider See Also: org.hibernate.cache.Cache author: mbatchel |