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 ICacheManagerprotected org.hibernate.cache.CacheProvider getCacheProvider()
org.hibernate.cache.CacheProviderpublic boolean cacheEnabled(String region)
cacheEnabled in interface ICacheManagerpublic void onLogout(IPentahoSession session)
onLogout in interface ICacheManageronLogout in interface ILogoutListenerpublic boolean addCacheRegion(String region, Properties cacheProperties)
addCacheRegion in interface ICacheManagerpublic boolean addCacheRegion(String region)
addCacheRegion in interface ICacheManagerpublic void clearRegionCache(String region)
clearRegionCache in interface ICacheManagerpublic void removeRegionCache(String region)
removeRegionCache in interface ICacheManagerpublic void putInRegionCache(String region, Object key, Object value)
putInRegionCache in interface ICacheManagerpublic Object getFromRegionCache(String region, Object key)
getFromRegionCache in interface ICacheManagerpublic List getAllValuesFromRegionCache(String region)
getAllValuesFromRegionCache in interface ICacheManagerpublic Set getAllKeysFromRegionCache(String region)
getAllKeysFromRegionCache in interface ICacheManagerpublic Set getAllEntriesFromRegionCache(String region)
getAllEntriesFromRegionCache in interface ICacheManagerpublic void removeFromRegionCache(String region, Object key)
removeFromRegionCache in interface ICacheManagerpublic boolean cacheEnabled()
cacheEnabled in interface ICacheManagerpublic void clearCache()
clearCache in interface ICacheManagerpublic Object getFromGlobalCache(Object key)
getFromGlobalCache in interface ICacheManagerpublic Object getFromSessionCache(IPentahoSession session, String key)
getFromSessionCache in interface ICacheManagerpublic void killSessionCache(IPentahoSession session)
killSessionCache in interface ICacheManagerpublic void killSessionCaches()
killSessionCaches in interface ICacheManagerpublic void putInGlobalCache(Object key, Object value)
putInGlobalCache in interface ICacheManagerpublic void putInSessionCache(IPentahoSession session, String key, Object value)
putInSessionCache in interface ICacheManagerpublic void removeFromGlobalCache(Object key)
removeFromGlobalCache in interface ICacheManagerpublic void removeFromSessionCache(IPentahoSession session, String key)
removeFromSessionCache in interface ICacheManagerpublic long getElementCountInRegionCache(String region)
getElementCountInRegionCache in interface ICacheManagerpublic long getElementCountInSessionCache()
getElementCountInSessionCache in interface ICacheManagerpublic long getElementCountInGlobalCache()
getElementCountInGlobalCache in interface ICacheManagerCopyright © 2017 Hitachi Vantara. All rights reserved.