public class TCacheFactory extends Object implements Closeable, javax.cache.CacheManager
builder(), and also supplies administrative methods for the
managed caches, like shutting down all registered Caches. The preferred way of obtaining a TCacheFactory
instance for application code is a call to standardFactory(). Library code should instantiate a new
TCacheFactory instance, so it can manage its own Cache collection.
An alternative way is to use the JCache API, and obtain an instance via CachingProvider.getCacheManager() calls.| Constructor and Description |
|---|
TCacheFactory()
Creates a TCacheFactory with default parameters.
|
TCacheFactory(URI uri,
ClassLoader classLoader,
Properties properties,
TCacheProvider cachingProvider) |
TCacheFactory(URI uri,
ClassLoader classLoader,
TCacheProvider cachingProvider) |
| Modifier and Type | Method and Description |
|---|---|
<K,V> Builder<K,V> |
builder()
Returns a Builder
|
void |
close()
Closes the TCacheFactory.
|
<K,V,C extends javax.cache.configuration.Configuration<K,V>> |
createCache(String cacheName,
C configuration) |
void |
destroyCache(String cacheName) |
void |
enableManagement(String cacheName,
boolean enable) |
void |
enableStatistics(String cacheName,
boolean enable) |
boolean |
equals(Object obj) |
<K,V> javax.cache.Cache<K,V> |
getCache(String cacheName) |
<K,V> javax.cache.Cache<K,V> |
getCache(String cacheName,
Class<K> keyClass,
Class<V> valueClass) |
Iterable<String> |
getCacheNames() |
javax.cache.spi.CachingProvider |
getCachingProvider() |
ClassLoader |
getClassLoader() |
Properties |
getProperties() |
Cache<?,?> |
getTCache(String cacheName) |
URI |
getURI() |
int |
hashCode() |
List<Cache<?,?>> |
instances()
Returns the list of Caches that have been registered via
registerCache(Cache). |
boolean |
isClosed() |
void |
registerCache(Cache<?,?> cache)
Registers a Cache to this factory.
|
Map<String,CacheSizeInfo> |
reportAllCacheSizes(ObjectSizeCalculatorInterface objectSizeCalculator)
Reports size of all Cache instances, which were registered via
registerCache(Cache). |
static TCacheFactory |
standardFactory()
Returns the standard factory.
|
<T> T |
unwrap(Class<T> clazz) |
public TCacheFactory()
JCache (JSR107) compatibility note. The TCacheFactory is a JSR107 CacheManager, but it is standalone and will not be registered in any CacheProvider. If you require this, retrieve an instance via the other constructors or the JSR107 CacheProvider instead.
public TCacheFactory(URI uri, ClassLoader classLoader, TCacheProvider cachingProvider)
public TCacheFactory(URI uri, ClassLoader classLoader, Properties properties, TCacheProvider cachingProvider)
public static TCacheFactory standardFactory()
builder().
public <K,V> Builder<K,V> builder()
K - The Key typeV - The Value typepublic void registerCache(Cache<?,?> cache)
close().cache - The Cache to registerIllegalStateException - If a cache with the same id is already registered in this factory.public void destroyCache(String cacheName)
destroyCache in interface javax.cache.CacheManagerpublic URI getURI()
getURI in interface javax.cache.CacheManagerpublic ClassLoader getClassLoader()
getClassLoader in interface javax.cache.CacheManagerpublic Properties getProperties()
getProperties in interface javax.cache.CacheManagerpublic void close()
For each Cache managed by the TCacheFactory, the
Cache#close() method will be invoked, in no guaranteed order.
If a Cache#close() call throws an exception, the exception will be ignored.
After executing this method, the isClosed() method will return
true.
All attempts to close a previously closed TCacheFactory will be ignored.
close in interface Closeableclose in interface AutoCloseableclose in interface javax.cache.CacheManagerSecurityException - when the operation could not be performed due to the
current security settingspublic boolean isClosed()
isClosed in interface javax.cache.CacheManagerpublic Map<String,CacheSizeInfo> reportAllCacheSizes(ObjectSizeCalculatorInterface objectSizeCalculator)
registerCache(Cache). Using
this method can create high load, and may require particular permissions, depending on the used object
size calculator.
USE WITH CARE!!!
objectSizeCalculator - An implementation that can calculate the deep size of an Object treepublic List<Cache<?,?>> instances()
registerCache(Cache).public <K,V,C extends javax.cache.configuration.Configuration<K,V>> javax.cache.Cache<K,V> createCache(String cacheName, C configuration) throws IllegalArgumentException
createCache in interface javax.cache.CacheManagerIllegalArgumentExceptionpublic void enableManagement(String cacheName, boolean enable)
enableManagement in interface javax.cache.CacheManagerpublic void enableStatistics(String cacheName, boolean enable)
enableStatistics in interface javax.cache.CacheManagerpublic <K,V> javax.cache.Cache<K,V> getCache(String cacheName, Class<K> keyClass, Class<V> valueClass)
getCache in interface javax.cache.CacheManagerpublic <K,V> javax.cache.Cache<K,V> getCache(String cacheName)
getCache in interface javax.cache.CacheManagerpublic Iterable<String> getCacheNames()
getCacheNames in interface javax.cache.CacheManagerpublic javax.cache.spi.CachingProvider getCachingProvider()
getCachingProvider in interface javax.cache.CacheManagerpublic <T> T unwrap(Class<T> clazz)
unwrap in interface javax.cache.CacheManagerCopyright © 2018 trivago. All rights reserved.