本文整理匯總了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 );
}