当前位置: 首页>>代码示例>>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;未经允许,请勿转载。