public abstract class CacheManager extends Object implements Closeable
Cache managers are identified by a unique name. If no name is specified the name
"default"
is used. The default name in use may be changed, see setDefaultName(String)
.
Modifier and Type | Field and Description |
---|---|
protected static Cache2kCoreProvider |
PROVIDER |
Constructor and Description |
---|
CacheManager() |
Modifier and Type | Method and Description |
---|---|
abstract void |
clear()
Clear all currently active caches in this cache manager
|
abstract void |
close()
Free all resources from managed caches.
|
static void |
close(ClassLoader cl,
String name)
Close the named cache manager.
|
static void |
closeAll()
Close all cache managers.
|
static void |
closeAll(ClassLoader cl)
Close all cache manager associated with this class loader.
|
abstract <K,V> Cache<K,V> |
createCache(Cache2kConfiguration<K,V> cfg)
Create a new cache from the configuration.
|
abstract Iterable<Cache> |
getActiveCaches()
Returns all caches created in this cache manager instance.
|
abstract <K,V> Cache<K,V> |
getCache(String name)
Return a known cache that must be created before via the
Cache2kBuilder
or createCache(Cache2kConfiguration) |
abstract ClassLoader |
getClassLoader()
Class loader this manager is using to load additional classes, resources or configuration.
|
static String |
getDefaultName()
Name of the default cache manager, which is "default" by default.
|
static CacheManager |
getInstance()
Get the default cache manager for the default class loader.
|
static CacheManager |
getInstance(ClassLoader cl)
Get the default cache manager for the specified class loader.
|
static CacheManager |
getInstance(ClassLoader cl,
String managerName)
Retrieve a cache manager with the specified name using the specified classloader.
|
static CacheManager |
getInstance(String managerName)
Retrieve a cache manager with the specified name.
|
abstract String |
getName()
The name to uniquely identify the manager within a VM instance.
|
abstract Properties |
getProperties()
Properties for the cache manager, never null.
|
abstract boolean |
isClosed()
Returns true if this cache manager was closed.
|
abstract boolean |
isDefaultManager()
True if this is the default manager of the application, returned by
getInstance() |
static void |
setDefaultName(String managerName)
Change the default manager name.
|
protected static final Cache2kCoreProvider PROVIDER
public static String getDefaultName()
public static void setDefaultName(String managerName)
It is also possible to set a different default manager name via JNDI context "java:comp/env" and name "org.cache2k.CacheManager.defaultName" or via the XML configuration.
The allowed characters in a manager name are identical to the characters in a cache name, this is
documented at Cache2kBuilder.name(String)
Cache2kBuilder.name(String)
public static CacheManager getInstance()
public static CacheManager getInstance(ClassLoader cl)
public static CacheManager getInstance(String managerName)
The allowed characters in a manager name are identical to the characters in a cache name, this is
documented at Cache2kBuilder.name(String)
Cache2kBuilder.name(String)
public static CacheManager getInstance(ClassLoader cl, String managerName)
The allowed characters in a manager name are identical to the characters in a cache name, this is
documented at Cache2kBuilder.name(String)
Cache2kBuilder.name(String)
public static void closeAll()
public static void closeAll(ClassLoader cl)
public static void close(ClassLoader cl, String name)
public abstract boolean isDefaultManager()
getInstance()
public abstract String getName()
getInstance(String)
public abstract Iterable<Cache> getActiveCaches()
public abstract <K,V> Cache<K,V> getCache(String name)
Cache2kBuilder
or createCache(Cache2kConfiguration)
public abstract <K,V> Cache<K,V> createCache(Cache2kConfiguration<K,V> cfg)
Cache2kBuilder
to create a new cache. This method is identical to and a shorthand to:
CacheManager manager = ...
Cache2kConfiguration<K,V> config = ...
Cache<K,V> cache = Cache2kBuilder.of(config).manager(manager).build();
public abstract void clear()
public abstract void close()
Cache.close()
methods.
A closed manager cannot be use the create new caches. A new instance of the same name may be requested
via getInstance(String)
.
Multiple calls to close have no effect.
close
in interface Closeable
close
in interface AutoCloseable
public abstract boolean isClosed()
close()
public abstract Properties getProperties()
public abstract ClassLoader getClassLoader()
cache2k API documentation. Copyright © 2000–2017 headissue GmbH, Munich.