public class CacheManager extends Object implements ICacheManager
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
CacheProvider
,
Cache
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
logger |
GLOBAL, SESSION
Constructor and Description |
---|
CacheManager()
The constructor performs the following tasks:
|
public CacheManager()
cache-provider/class
element.cache-provider/region
element.cache-provider/properties/*
org.hibernate.cache.CacheProvider
interface)org.hibernate.cache.CacheProvider
interface)protected void setupCacheProvider(Properties cacheProperties)
public void cacheStop()
cacheStop
in interface ICacheManager
protected org.hibernate.cache.CacheProvider getCacheProvider()
org.hibernate.cache.CacheProvider
public boolean cacheEnabled(String region)
cacheEnabled
in interface ICacheManager
public void onLogout(IPentahoSession session)
onLogout
in interface ICacheManager
onLogout
in interface ILogoutListener
public boolean addCacheRegion(String region, Properties cacheProperties)
addCacheRegion
in interface ICacheManager
public boolean addCacheRegion(String region)
addCacheRegion
in interface ICacheManager
public void clearRegionCache(String region)
clearRegionCache
in interface ICacheManager
public void removeRegionCache(String region)
removeRegionCache
in interface ICacheManager
public void putInRegionCache(String region, Object key, Object value)
putInRegionCache
in interface ICacheManager
public Object getFromRegionCache(String region, Object key)
getFromRegionCache
in interface ICacheManager
public List getAllValuesFromRegionCache(String region)
getAllValuesFromRegionCache
in interface ICacheManager
public Set getAllKeysFromRegionCache(String region)
getAllKeysFromRegionCache
in interface ICacheManager
public Set getAllEntriesFromRegionCache(String region)
getAllEntriesFromRegionCache
in interface ICacheManager
public void removeFromRegionCache(String region, Object key)
removeFromRegionCache
in interface ICacheManager
public boolean cacheEnabled()
cacheEnabled
in interface ICacheManager
public void clearCache()
clearCache
in interface ICacheManager
public Object getFromGlobalCache(Object key)
getFromGlobalCache
in interface ICacheManager
public Object getFromSessionCache(IPentahoSession session, String key)
getFromSessionCache
in interface ICacheManager
public void killSessionCache(IPentahoSession session)
killSessionCache
in interface ICacheManager
public void killSessionCaches()
killSessionCaches
in interface ICacheManager
public void putInGlobalCache(Object key, Object value)
putInGlobalCache
in interface ICacheManager
public void putInSessionCache(IPentahoSession session, String key, Object value)
putInSessionCache
in interface ICacheManager
public void removeFromGlobalCache(Object key)
removeFromGlobalCache
in interface ICacheManager
public void removeFromSessionCache(IPentahoSession session, String key)
removeFromSessionCache
in interface ICacheManager
public long getElementCountInRegionCache(String region)
getElementCountInRegionCache
in interface ICacheManager
public long getElementCountInSessionCache()
getElementCountInSessionCache
in interface ICacheManager
public long getElementCountInGlobalCache()
getElementCountInGlobalCache
in interface ICacheManager
Copyright © 2017 Hitachi Vantara. All rights reserved.