use of javax.cache.CacheManager in project ignite by apache.
the class CacheStopAndDestroySelfTest method testTckStyleCreateDestroyClose.
/**
* Tests start -> destroy -> start -> close using CacheManager.
*/
public void testTckStyleCreateDestroyClose() throws Exception {
startGridsMultiThreaded(gridCount());
CacheManager mgr = Caching.getCachingProvider().getCacheManager();
String cacheName = "cache";
mgr.createCache(cacheName, new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class));
mgr.destroyCache(cacheName);
Cache<Integer, String> cache = mgr.createCache(cacheName, new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class));
cache.close();
cache.close();
try {
cache.get(1);
fail();
} catch (IllegalStateException ignored) {
// No-op;
}
}
use of javax.cache.CacheManager in project caffeine by ben-manes.
the class CaffeineCachingProvider method getCacheManager.
@Override
public CacheManager getCacheManager(URI uri, ClassLoader classLoader, Properties properties) {
URI managerURI = getManagerUri(uri);
ClassLoader managerClassLoader = getManagerClassLoader(classLoader);
synchronized (cacheManagers) {
Map<URI, CacheManager> cacheManagersByURI = cacheManagers.computeIfAbsent(managerClassLoader, any -> new HashMap<>());
return cacheManagersByURI.computeIfAbsent(managerURI, any -> {
Properties managerProperties = (properties == null) ? getDefaultProperties() : properties;
return new CacheManagerImpl(this, managerURI, managerClassLoader, managerProperties);
});
}
}
use of javax.cache.CacheManager in project caffeine by ben-manes.
the class CaffeineCachingProvider method close.
@Override
public void close(ClassLoader classLoader) {
synchronized (cacheManagers) {
ClassLoader managerClassLoader = getManagerClassLoader(classLoader);
Map<URI, CacheManager> cacheManagersByURI = cacheManagers.remove(managerClassLoader);
if (cacheManagersByURI != null) {
for (CacheManager cacheManager : cacheManagersByURI.values()) {
cacheManager.close();
}
}
}
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheConfigTest method defaultCacheTest.
@Test
public void defaultCacheTest() {
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
assertNotNull(cacheManager);
Cache testCache = cacheManager.getCache("default");
assertNull(testCache);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheConfigTest method testEntryListenerFactoryFromSimpleCacheConfig.
@Test
public void testEntryListenerFactoryFromSimpleCacheConfig() {
String cacheName = randomString();
Config config = createConfig(cacheName);
HazelcastInstance instance = createHazelcastInstance(config);
HazelcastServerCachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
Cache<Object, Object> cache = cacheManager.getCache(cacheName);
EntryListener.latch = new CountDownLatch(1);
cache.put(randomString(), randomString());
assertOpenEventually(EntryListener.latch);
}
Aggregations