CacheManager provides a means of establishing, configuring,
acquiring, closing and destroying uniquely named Caches.
Caches produced and owned by a CacheManager typically share
common infrastructure, for example, a common ClassLoader and
implementation specific Properties.
Implementations of CacheManager may additionally provide and share
external resources between the Caches being managed, for example,
the content of the managed Caches may be stored in the same cluster.
By default CacheManager instances are typically acquired through the
use of a CachingProvider. Implementations however may additionally
provide other mechanisms to create, acquire, manage and configure
CacheManagers, including:
java.util.ServiceLoaders,new operator to create a
concrete implementation,
The default CacheManager however can always be acquired using the
default configured CachingProvider obtained by the Caching
class. For example:
CachingProvider provider = Caching.getCachingProvider();
CacheManager manager = provider.getCacheManager();
Within a Java process CacheManagers and the Caches they
manage are scoped and uniquely identified by a URI, the meaning of
which is implementation specific. To obtain the default URI,
ClassLoader and Properties for an implementation, consult the
CachingProvider class.
Caching, CachingProvider, Cache
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public < the type of key K, the type of value V, the type of the Configuration C extends Configuration | createCache(String
the name of the cacheName, C Cache. Names should not use
forward slashes(/) or colons(:), or start with
java. or javax. These prefixes are reserved.a configuration)Configuration for the CacheCreates a named |
| public void | |
| public void | enableManagement(String
the name of the cache to register cacheName, boolean true to enable management, false to disable. enabled)Controls whether management is enabled. |
| public void | enableStatistics(String
the name of the cache to register cacheName, boolean true to enable statistics, false to disable. enabled)Enables or disables statistics gathering for a managed |
| public < the type of key K, the type of value V> Cache | |
| public < the type of key K, the type of value V> Cache | |
| public Iterable | |
| public CachingProvider | Returns: the CachingProvider ornull if the CacheManager
was created without using a CachingProviderGet the |
| public ClassLoader | |
| public Properties | Returns: the Properties used to create theCacheManagerGet the |
| public URI | |
| public boolean | Returns: true if thisCacheManager instance is closed; false if it
is still openDetermines whether the |
| public < the type of the underlying T> TCacheManager | Returns: an instance of the underlying concreteCacheManagerthe proprietary class or interface of the underlying concrete
clazz)CacheManager. It is this type that is returned.Provides a standard mechanism to access the underlying concrete caching implementation to provide access to further, proprietary features. |
| close | back to summary |
|---|---|
| public void close() Redeclares java. Closes the
For each
If a
After executing this method, the
All attempts to close a previously closed It simply signals that the CacheManager is no longer required by the application and that future uses of a specific CacheManager instance should not be permitted. Depending on the implementation and Cache topology, (e.g. a storage-backed or distributed cache), the contents of closed Caches previously referenced by the CacheManager, may still be available and accessible by other applications.
| |
| createCache | back to summary |
|---|---|
| public <K, V, C extends Configuration Creates a named
If a
If a
Prior to a
Implementers should be aware that the
There's no requirement on the part of a developer to call this method for
each
| |
| destroyCache | back to summary |
|---|---|
| public void destroyCache(String cacheName) Destroys a specifically named and managed This is equivalent to the following sequence of method calls: followed by allowing the name of theCache to be used for other
Cache configurations.
From the time this method is called, the specified
| |
| enableManagement | back to summary |
|---|---|
| public void enableManagement(String cacheName, boolean enabled) Controls whether management is enabled. If enabled the Management information includes the name and configuration information for the cache. Each cache's management object must be registered with an ObjectName that is unique and has the following type and attributes:
Type:
Required Attributes:
| |
| enableStatistics | back to summary |
|---|---|
| public void enableStatistics(String cacheName, boolean enabled) Enables or disables statistics gathering for a managed Each cache's statistics object must be registered with an ObjectName that is unique and has the following type and attributes:
Type:
Required Attributes:
| |
| getCache | back to summary |
|---|---|
| public <K, V> Cache Looks up a managed Use this method to check runtime key and value types.
Use
Implementations must ensure that the key and value types are the same as
those configured for the
Implementations may further perform type checking on mutative cache operations
and throw a
Implementations that support declarative mechanisms for pre-configuring
| |
| getCache | back to summary |
|---|---|
| public <K, V> Cache Looks up a managed
This method may only be used to acquire
Use the
Implementations that support declarative mechanisms for pre-configuring
| |
| getCacheNames | back to summary |
|---|---|
| public Iterable Obtains an
| |
| getCachingProvider | back to summary |
|---|---|
| public CachingProvider getCachingProvider() Get the
| |
| getClassLoader | back to summary |
|---|---|
| public ClassLoader getClassLoader() Get the
| |
| getProperties | back to summary |
|---|---|
| public Properties getProperties() Get the
Implementations are not required to re-configure the
| |
| getURI | back to summary |
|---|---|
| public URI getURI() Get the URI of the
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Determines whether the
This method generally cannot be called to determine whether the
| |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> clazz) Provides a standard mechanism to access the underlying concrete caching implementation to provide access to further, proprietary features.
If the provider's implementation does not support the specified class,
the
| |