本文整理汇总了Java中javax.cache.Cache.close方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.close方法的具体用法?Java Cache.close怎么用?Java Cache.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.cache.Cache
的用法示例。
在下文中一共展示了Cache.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import javax.cache.Cache; //导入方法依赖的package包/类
@Override
public void close() {
if (isClosed()) {
return;
}
synchronized (cacheProvider) {
if (!isClosed()) {
cacheProvider.close(uri, classLoader);
for (Cache<?, ?> cache : caches.values()) {
try {
cache.close();
} catch (Exception e) {
// skip
}
}
redisson.shutdown();
closed = true;
}
}
}
示例2: testRedissonConfig
import javax.cache.Cache; //导入方法依赖的package包/类
@Test
public void testRedissonConfig() throws InterruptedException, IllegalArgumentException, URISyntaxException, IOException {
RedisProcess runner = new RedisRunner()
.nosave()
.randomDir()
.port(6311)
.run();
URL configUrl = getClass().getResource("redisson-jcache.json");
Config cfg = Config.fromJSON(configUrl);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
.createCache("test", config);
cache.put("1", "2");
Assert.assertEquals("2", cache.get("1"));
cache.close();
runner.stop();
}
示例3: testRedissonInstance
import javax.cache.Cache; //导入方法依赖的package包/类
@Test
public void testRedissonInstance() throws InterruptedException, IllegalArgumentException, URISyntaxException {
Configuration<String, String> config = RedissonConfiguration.fromInstance(redisson);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
.createCache("test", config);
cache.put("1", "2");
Assert.assertEquals("2", cache.get("1"));
cache.close();
}
示例4: testExpiration
import javax.cache.Cache; //导入方法依赖的package包/类
@Test
public void testExpiration() throws InterruptedException, IllegalArgumentException, URISyntaxException, FailedToStartRedisException, IOException {
RedisProcess runner = new RedisRunner()
.nosave()
.randomDir()
.port(6311)
.run();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.json").toURI();
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager(configUri, null)
.createCache("test", config);
CountDownLatch latch = new CountDownLatch(1);
String key = "123";
ExpiredListener clientListener = new ExpiredListener(latch, key, "90");
MutableCacheEntryListenerConfiguration<String, String> listenerConfiguration =
new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(clientListener), null, true, true);
cache.registerCacheEntryListener(listenerConfiguration);
cache.put(key, "90");
Assert.assertNotNull(cache.get(key));
latch.await();
Assert.assertNull(cache.get(key));
cache.close();
runner.stop();
}
示例5: destroyCache
import javax.cache.Cache; //导入方法依赖的package包/类
@Override
public void destroyCache(final String cacheName) {
checkClosed();
final Cache<?,?> cache = nameToCache.remove( cacheName );
if(cache!=null){
cache.close();
}
}
示例6: close
import javax.cache.Cache; //导入方法依赖的package包/类
@Override
public void close() {
for(final Cache<?,?> cache : nameToCache.values()){
cache.close();
}
closed.set( false );
}