當前位置: 首頁>>代碼示例>>Java>>正文


Java Cache.close方法代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:22,代碼來源:JCacheManager.java

示例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();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:22,代碼來源:JCacheTest.java

示例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();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:12,代碼來源:JCacheTest.java

示例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();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:35,代碼來源:JCacheTest.java

示例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();
	}
}
 
開發者ID:candrews,項目名稱:hibernate-springcache,代碼行數:9,代碼來源:SpringCacheManagerToJCacheManagerAdapter.java

示例6: close

import javax.cache.Cache; //導入方法依賴的package包/類
@Override
public void close() {
	for(final Cache<?,?> cache : nameToCache.values()){
		cache.close();
	}
	closed.set( false );
}
 
開發者ID:candrews,項目名稱:hibernate-springcache,代碼行數:8,代碼來源:SpringCacheManagerToJCacheManagerAdapter.java


注:本文中的javax.cache.Cache.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。