|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pentaho.platform.plugin.services.cache.CacheManager
public class CacheManager
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
CacheProvider,
Cache| Field Summary |
|---|
| Fields inherited from interface org.pentaho.platform.api.engine.ICacheManager |
|---|
GLOBAL, SESSION |
| Constructor Summary | |
|---|---|
CacheManager()
The constructor performs the following tasks: |
|
| Method Summary | |
|---|---|
boolean |
addCacheRegion(java.lang.String region)
|
boolean |
addCacheRegion(java.lang.String region,
java.util.Properties cacheProperties)
|
boolean |
cacheEnabled()
Returns the enablement state of the cache. |
boolean |
cacheEnabled(java.lang.String region)
Returns the enablement state of the cache. |
void |
cacheStop()
Stops the cache by calling the cacheProvider stop method. |
void |
clearCache()
Entirely clears the cache. |
void |
clearRegionCache(java.lang.String region)
Clears any data for the specified for a specific region(For example region could be session, global etc) |
java.util.Set |
getAllEntriesFromRegionCache(java.lang.String region)
Get a Set of Map.Entry objects from the cache within a specific region |
java.util.Set |
getAllKeysFromRegionCache(java.lang.String region)
Get a Set of Key objects from the cache within a specific region |
java.util.List |
getAllValuesFromRegionCache(java.lang.String region)
Get a list of values from the cache within a specific region |
java.lang.Object |
getFromGlobalCache(java.lang.Object key)
Gets an object from the cache without translating the passed in key. |
java.lang.Object |
getFromRegionCache(java.lang.String region,
java.lang.Object key)
Gets an object from the cache within a specific region |
java.lang.Object |
getFromSessionCache(IPentahoSession session,
java.lang.String key)
Gets an object from the user session specific cache. |
void |
killSessionCache(IPentahoSession session)
Removes any session-based data for the specified IPentahoSession. |
void |
killSessionCaches()
Removes all cached items that are session-based. |
void |
onLogout(IPentahoSession session)
|
void |
putInGlobalCache(java.lang.Object key,
java.lang.Object value)
Puts an object directly into the cache without translating the passed in key. |
void |
putInRegionCache(java.lang.String region,
java.lang.Object key,
java.lang.Object value)
Puts an object directly into the cache of a specific region |
void |
putInSessionCache(IPentahoSession session,
java.lang.String key,
java.lang.Object value)
Puts an object in the session-specific cache. |
void |
removeFromGlobalCache(java.lang.Object key)
Removes an object from the cache |
void |
removeFromRegionCache(java.lang.String region,
java.lang.Object key)
Removes an object from the cache within a specific region |
void |
removeFromSessionCache(IPentahoSession session,
java.lang.String key)
Removes a data item from the user session specific cache |
void |
removeRegionCache(java.lang.String region)
Clears any data for the specified for a specific region(For example region could be session, global etc) and removed the region from the map |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CacheManager()
cache-provider/class element.cache-provider/region element.cache-provider/properties/*org.hibernate.cache.CacheProvider interface)org.hibernate.cache.CacheProvider interface)
| Method Detail |
|---|
public void cacheStop()
ICacheManager
cacheStop in interface ICacheManagerpublic boolean cacheEnabled(java.lang.String region)
ICacheManager
cacheEnabled in interface ICacheManagerpublic void onLogout(IPentahoSession session)
onLogout in interface ICacheManageronLogout in interface ILogoutListenersession - Performs any logout actions based on this session.
public boolean addCacheRegion(java.lang.String region,
java.util.Properties cacheProperties)
addCacheRegion in interface ICacheManagerpublic boolean addCacheRegion(java.lang.String region)
addCacheRegion in interface ICacheManagerpublic void clearRegionCache(java.lang.String region)
ICacheManager
clearRegionCache in interface ICacheManagerregion - The region whose objects needs to be removed from the cache.public void removeRegionCache(java.lang.String region)
ICacheManager
removeRegionCache in interface ICacheManagerregion - The region whose objects needs to be removed from the cache.
public void putInRegionCache(java.lang.String region,
java.lang.Object key,
java.lang.Object value)
ICacheManagerImportant note - most cache implementations require both the key and the value to be serializable.
putInRegionCache in interface ICacheManagerkey - Object by which the data is indexedvalue - The data to store in the cache.
public java.lang.Object getFromRegionCache(java.lang.String region,
java.lang.Object key)
ICacheManager
getFromRegionCache in interface ICacheManagerregion - the region where the object was put in the cachekey - The key that the data object was stored with
public java.util.List getAllValuesFromRegionCache(java.lang.String region)
ICacheManager
getAllValuesFromRegionCache in interface ICacheManagerregion - the region where the object was put in the cache
public java.util.Set getAllKeysFromRegionCache(java.lang.String region)
ICacheManager
getAllKeysFromRegionCache in interface ICacheManagerregion - the region where the object was put in the cache
public java.util.Set getAllEntriesFromRegionCache(java.lang.String region)
ICacheManager
getAllEntriesFromRegionCache in interface ICacheManagerregion - the region where the object was put in the cache
public void removeFromRegionCache(java.lang.String region,
java.lang.Object key)
ICacheManager
removeFromRegionCache in interface ICacheManagerregion - the region where the object was put in the cachekey - The key that the data object was stored withpublic boolean cacheEnabled()
ICacheManager
cacheEnabled in interface ICacheManagerpublic void clearCache()
ICacheManager
clearCache in interface ICacheManagerpublic java.lang.Object getFromGlobalCache(java.lang.Object key)
ICacheManager
getFromGlobalCache in interface ICacheManagerkey - The key that the data object was stored with
public java.lang.Object getFromSessionCache(IPentahoSession session,
java.lang.String key)
ICacheManager
getFromSessionCache in interface ICacheManagersession - The users IPentahoSessionkey - The key that maps to the data to get from the cache
public void killSessionCache(IPentahoSession session)
ICacheManagerIPentahoSession.
killSessionCache in interface ICacheManagersession - The session whose objects needs to be removed from the cache.public void killSessionCaches()
ICacheManager
killSessionCaches in interface ICacheManager
public void putInGlobalCache(java.lang.Object key,
java.lang.Object value)
ICacheManagerImportant note - most cache implementations require both the key and the value to be serializable.
putInGlobalCache in interface ICacheManagerkey - Object by which the data is indexedvalue - The data to store in the cache.
public void putInSessionCache(IPentahoSession session,
java.lang.String key,
java.lang.Object value)
ICacheManager
Take special care that, in a TestCase, you don't have multiple
StandaloneSession objects with the same session key. Consider using
UUIDUtil to generate a unique sessionId for each
standalone session.
putInSessionCache in interface ICacheManagersession - The users IPentahoSessionkey - The key by which you want to retrieve the data back outvalue - The data item to place into the cachepublic void removeFromGlobalCache(java.lang.Object key)
ICacheManager
removeFromGlobalCache in interface ICacheManagerkey - The key that the data object was stored with
public void removeFromSessionCache(IPentahoSession session,
java.lang.String key)
ICacheManager
removeFromSessionCache in interface ICacheManagersession - The users IPentahoSessionkey - The key that maps to the value needing removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||