public class CacheManager extends Object implements org.pentaho.platform.api.engine.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 |
Constructor and Description |
---|
CacheManager()
The constructor performs the following tasks:
|
Modifier and Type | Method and Description |
---|---|
boolean |
addCacheRegion(String region) |
boolean |
addCacheRegion(String region,
org.hibernate.cache.Cache cache) |
boolean |
addCacheRegion(String region,
Properties cacheProperties) |
boolean |
cacheEnabled() |
boolean |
cacheEnabled(String region) |
void |
cacheStop() |
void |
clearCache() |
void |
clearRegionCache(String region) |
Set |
getAllEntriesFromRegionCache(String region) |
Set |
getAllKeysFromRegionCache(String region) |
List |
getAllValuesFromRegionCache(String region) |
protected org.hibernate.cache.CacheProvider |
getCacheProvider()
Returns the underlying cache provider (implements
org.hibernate.cache.CacheProvider |
long |
getElementCountInGlobalCache() |
long |
getElementCountInRegionCache(String region) |
long |
getElementCountInSessionCache() |
Object |
getFromGlobalCache(Object key) |
Object |
getFromRegionCache(String region,
Object key) |
Object |
getFromSessionCache(org.pentaho.platform.api.engine.IPentahoSession session,
String key) |
void |
killSessionCache(org.pentaho.platform.api.engine.IPentahoSession session) |
void |
killSessionCaches() |
void |
onLogout(org.pentaho.platform.api.engine.IPentahoSession session) |
void |
putInGlobalCache(Object key,
Object value) |
void |
putInRegionCache(String region,
Object key,
Object value) |
void |
putInSessionCache(org.pentaho.platform.api.engine.IPentahoSession session,
String key,
Object value) |
void |
removeFromGlobalCache(Object key) |
void |
removeFromRegionCache(String region,
Object key) |
void |
removeFromSessionCache(org.pentaho.platform.api.engine.IPentahoSession session,
String key) |
void |
removeRegionCache(String region) |
protected void |
setupCacheProvider(Properties cacheProperties) |
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 org.pentaho.platform.api.engine.ICacheManager
protected org.hibernate.cache.CacheProvider getCacheProvider()
org.hibernate.cache.CacheProvider
public boolean cacheEnabled(String region)
cacheEnabled
in interface org.pentaho.platform.api.engine.ICacheManager
public void onLogout(org.pentaho.platform.api.engine.IPentahoSession session)
onLogout
in interface org.pentaho.platform.api.engine.ICacheManager
onLogout
in interface org.pentaho.platform.api.engine.ILogoutListener
public boolean addCacheRegion(String region, Properties cacheProperties)
addCacheRegion
in interface org.pentaho.platform.api.engine.ICacheManager
public boolean addCacheRegion(String region)
addCacheRegion
in interface org.pentaho.platform.api.engine.ICacheManager
public boolean addCacheRegion(String region, org.hibernate.cache.Cache cache)
public void clearRegionCache(String region)
clearRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void removeRegionCache(String region)
removeRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void putInRegionCache(String region, Object key, Object value)
putInRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public Object getFromRegionCache(String region, Object key)
getFromRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public List getAllValuesFromRegionCache(String region)
getAllValuesFromRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public Set getAllKeysFromRegionCache(String region)
getAllKeysFromRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public Set getAllEntriesFromRegionCache(String region)
getAllEntriesFromRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void removeFromRegionCache(String region, Object key)
removeFromRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public boolean cacheEnabled()
cacheEnabled
in interface org.pentaho.platform.api.engine.ICacheManager
public void clearCache()
clearCache
in interface org.pentaho.platform.api.engine.ICacheManager
public Object getFromGlobalCache(Object key)
getFromGlobalCache
in interface org.pentaho.platform.api.engine.ICacheManager
public Object getFromSessionCache(org.pentaho.platform.api.engine.IPentahoSession session, String key)
getFromSessionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void killSessionCache(org.pentaho.platform.api.engine.IPentahoSession session)
killSessionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void killSessionCaches()
killSessionCaches
in interface org.pentaho.platform.api.engine.ICacheManager
public void putInGlobalCache(Object key, Object value)
putInGlobalCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void putInSessionCache(org.pentaho.platform.api.engine.IPentahoSession session, String key, Object value)
putInSessionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void removeFromGlobalCache(Object key)
removeFromGlobalCache
in interface org.pentaho.platform.api.engine.ICacheManager
public void removeFromSessionCache(org.pentaho.platform.api.engine.IPentahoSession session, String key)
removeFromSessionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public long getElementCountInRegionCache(String region)
getElementCountInRegionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public long getElementCountInSessionCache()
getElementCountInSessionCache
in interface org.pentaho.platform.api.engine.ICacheManager
public long getElementCountInGlobalCache()
getElementCountInGlobalCache
in interface org.pentaho.platform.api.engine.ICacheManager
Copyright © 2021 Hitachi Vantara. All rights reserved.