|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CacheManager
A CacheManager is the primary mechanism for retrieving a Cache
instance, and is often
used as a starting point to using the Cache
.
Configuration
or a path or URL to a configuration XML file.
Lifecycle - CacheManagers have a lifecycle (it implements Lifecycle
) and the
default constructors also call Lifecycle.start()
. Overloaded versions of the constructors are available, that do not
start the CacheManager, although it must be kept in mind that CacheManagers need to be started
before they can be used to create Cache instances.
Once constructed, CacheManagers should be made available to any component that requires a Cache,
via JNDI or via some other mechanism such as an IoC container.
You obtain Cache instances from the CacheManager by using one of the overloaded
getCache(), methods. Note that with getCache(), there is no guarantee that the instance you get is
brand-new and empty, since caches are named and shared. Because of this, the CacheManager also acts as a
repository of Caches, and is an effective mechanism of looking up or creating Caches on demand.
When the system shuts down, it should call Lifecycle.stop()
on the CacheManager. This will ensure all caches
within its scope are properly stopped as well.
Sample usage: CacheManager manager = CacheManager.getInstance("my-config-file.xml"); Cache entityCache =
manager.getCache("myEntityCache"); entityCache.put("aPerson", new Person());
Configuration myNewConfiguration = new Configuration(); myNewConfiguration.setCacheMode(Configuration.CacheMode.LOCAL);
manager.defineCache("myLocalCache", myNewConfiguration); Cache localCache = manager.getCache("myLocalCache");
Method Summary | ||
---|---|---|
void |
defineCache(String cacheName,
Configuration configurationOverride)
Defines a named cache. |
|
Address |
getAddress()
|
|
|
getCache()
Retrieves the default cache associated with this cache manager. |
|
|
getCache(String cacheName)
Retrieves a named cache from the system. |
|
String |
getClusterName()
|
|
List<Address> |
getMembers()
|
|
ComponentStatus |
getStatus()
|
|
boolean |
isCoordinator()
|
Methods inherited from interface org.infinispan.lifecycle.Lifecycle |
---|
start, stop |
Methods inherited from interface org.infinispan.notifications.Listenable |
---|
addListener, getListeners, removeListener |
Method Detail |
---|
void defineCache(String cacheName, Configuration configurationOverride) throws DuplicateCacheNameException
cacheName
- name of cache to defineconfigurationOverride
- configuration overrides to use
DuplicateCacheNameException
- if the name is already in use.<K,V> Cache<K,V> getCache()
<K,V> Cache<K,V> getCache(String cacheName)
defineCache(String, org.infinispan.config.Configuration)
method, or declared in the configuration file.
cacheName
- name of cache to retrieve
String getClusterName()
List<Address> getMembers()
Address getAddress()
boolean isCoordinator()
ComponentStatus getStatus()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |