|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.p13n.cache.CacheFactory
Factory to create Singleton Cache objects. This implementation can be used by clients running inside of the CacheMBean application context (eg, most EJBs) as well as clients running outside of that context (eg, JDBC Connection Pools).
Constructor Summary | |
CacheFactory()
|
Method Summary | |
static boolean |
cacheExists(String cacheName)
Determine whether named cache exists in our collection |
static void |
flush(String cacheName)
Performs a cluster-aware flush of a given cache. |
static void |
flush(String cacheName,
Serializable cacheKey)
Performs a cluster-aware flush of the given cache's key. |
static Cache |
getCache(String name)
Create a new or access an existing Cache. |
static String[] |
getCacheNames()
Returns all Cache names |
static void |
removeCache(String cacheName)
Remove a cache from the system. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CacheFactory()
Method Detail |
public static boolean cacheExists(String cacheName)
public static void flush(String cacheName)
flush(cacheName,null)
.
public static void flush(String cacheName, Serializable cacheKey)
Flushing a cache key will call CacheFactory.getCache(cacheName).remove(cacheKey) on each node in the cluster. Flushing an entire cache calls CacheFactory.removeCache(cacheName) on each node.
The keys for caches to be flushed must be serializable so the key can be broadcast to other nodes. Cache entries with non-serializable keys can not be flushed this way.
The assumption inherrent in this design is that each node will retrieve and cache its own data. When the "real" data (i.e. in a database) changes, you want to clear all caches, cluster-wide, so on next access the cache will be empty, causing that node to re-fetch the data from the store.
The pattern for cached data that needs to be cluster-aware is something like:
database.update( newData ); // change backing data CacheFactory.flush( "myCache", "myData" ); // cluster-wide flush CacheFactory.getCache( "myCache" ).put( "myData", newData ); // cache locally
cacheName
- the name of the cache to be flushedcacheKey
- the key in that cache to remove. If null, clear the
entire cache.flush(String)
public static Cache getCache(String name)
If the cache has been pre-configured using MBeans, then create an instance of a cache with those parameters and return it. If the cache has not been pre-configured with MBeans, then create a cache with default parameters (defined in CacheDefaults) and return it.
If the cache exists already in the CacheFactory's collection (eg, it has been created by a previous call to CacheFactory.getCache()), then return an instance of that named cache.
name
- the name of the cache to create or retrieve
CacheDefaults
public static String[] getCacheNames()
public static void removeCache(String cacheName)
cacheName
- The name of the cache to remove.
|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |