当前位置: 首页>>代码示例>>Java>>正文


Java CachingProvider.close方法代码示例

本文整理汇总了Java中javax.cache.spi.CachingProvider.close方法的典型用法代码示例。如果您正苦于以下问题:Java CachingProvider.close方法的具体用法?Java CachingProvider.close怎么用?Java CachingProvider.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.cache.spi.CachingProvider的用法示例。


在下文中一共展示了CachingProvider.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetCachingProviders

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testGetCachingProviders()
{
    int instances = 0;

    for (CachingProvider cp : Caching.getCachingProviders())
    {
        if (cp.getClass().getName().equals(GuavaCachingProvider.class.getName()))
        {
            instances++;
        }

        cp.close();
    }

    assertEquals(1, instances);
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:18,代码来源:GuavaCachingProviderTest.java

示例2: testSimpleJCache

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testSimpleJCache() {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager();
    Cache<String, String> cache = manager.getCache("simple-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 5).forEach(i -> cache.put("key" + i, "value" + i));

    assertThat(cache.get("key1"))
        .isEqualTo("value1");
    assertThat(cache.get("key5"))
        .isEqualTo("value5");
    assertThat(cache.get("key10"))
        .isNull();

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:22,代码来源:JCacheConfigurationTest.java

示例3: closeCacheManagerByURIAndClassLoader

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void closeCacheManagerByURIAndClassLoader() {
  CachingProvider provider = Caching.getCachingProvider();

  ClassLoader loader1 = CLASS_LOADER;
  CacheManager manager1 = provider.getCacheManager(provider.getDefaultURI(), loader1, null);

  ClassLoader loader2 = new MyClassLoader(CLASS_LOADER);
  CacheManager manager2 = provider.getCacheManager(provider.getDefaultURI(), loader2, null);

  provider.close(manager1.getURI(), loader1);
  provider.close(manager2.getURI(), loader2);

  assertNotSame(manager1, provider.getCacheManager(provider.getDefaultURI(), loader1, null));
  assertNotSame(manager2, provider.getCacheManager(provider.getDefaultURI(), loader2, null));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:17,代码来源:CachingProviderTest.java

示例4: closeCacheManagersByClassLoader

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void closeCacheManagersByClassLoader() {
  CachingProvider provider = Caching.getCachingProvider();

  ClassLoader loader1 = CLASS_LOADER;
  CacheManager manager1 = provider.getCacheManager(provider.getDefaultURI(), loader1, null);

  ClassLoader loader2 = new MyClassLoader(CLASS_LOADER);
  CacheManager manager2 = provider.getCacheManager(provider.getDefaultURI(), loader2, null);

  provider.close(loader1);
  provider.close(loader2);

  assertNotSame(manager1, provider.getCacheManager(provider.getDefaultURI(), loader1, null));
  assertNotSame(manager2, provider.getCacheManager(provider.getDefaultURI(), loader2, null));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:17,代码来源:CachingProviderTest.java

示例5: closeAllCacheManagers

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
/**
 * Close all CacheManagers from a CachingProvider, each CacheManager being
 * based on a different ClassLoader.
 */
@Test
public void closeAllCacheManagers() throws Exception {
  ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();

  CachingProvider provider = Caching.getCachingProvider(contextLoader);

  URI uri = provider.getDefaultURI();

  ClassLoader loader1 = new MyClassLoader(contextLoader);
  CacheManager manager1 = provider.getCacheManager(uri, loader1);

  ClassLoader loader2 = new MyClassLoader(contextLoader);
  CacheManager manager2 = provider.getCacheManager(uri, loader2);

  ClassLoader loader3 = new MyClassLoader(contextLoader);
  CacheManager manager3 = provider.getCacheManager(uri, loader3);

  provider.close();

  assertNotSame(manager1, provider.getCacheManager(uri, loader1));
  assertNotSame(manager2, provider.getCacheManager(uri, loader2));
  assertNotSame(manager3, provider.getCacheManager(uri, loader3));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:28,代码来源:CachingProviderClassLoaderTest.java

示例6: closeCacheManager

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
/**
 * Closing a single CacheManager from a CachingProvider when there are
 * multiple available across different ClassLoaders.
 */
@Test
public void closeCacheManager() throws Exception {
  ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();

  CachingProvider provider = Caching.getCachingProvider(contextLoader);

  URI uri = provider.getDefaultURI();

  ClassLoader loader1 = new MyClassLoader(contextLoader);
  CacheManager manager1 = provider.getCacheManager(uri, loader1);

  ClassLoader loader2 = new MyClassLoader(contextLoader);
  CacheManager manager2 = provider.getCacheManager(uri, loader2);

  ClassLoader loader3 = new MyClassLoader(contextLoader);
  CacheManager manager3 = provider.getCacheManager(uri, loader3);

  provider.close(manager2.getURI(), loader2);

  assertSame(manager1, provider.getCacheManager(uri, loader1));
  assertNotSame(manager2, provider.getCacheManager(uri, loader2));
  assertSame(manager3, provider.getCacheManager(uri, loader3));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:28,代码来源:CachingProviderClassLoaderTest.java

示例7: testSimpleJCache

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testSimpleJCache() {
    Properties properties = new Properties();
    properties.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,
                           "classpath:my-hazelcast.xml");

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager(URI.create("my-cache-manager"),
                                                    null,
                                                    properties);
    Cache<String, String> cache = manager.getCache("simple-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 5).forEach(i -> cache.put("key" + i, "value" + i));

    assertThat(cache.get("key1"))
        .isEqualTo("value1");
    assertThat(cache.get("key5"))
        .isEqualTo("value5");
    assertThat(cache.get("key10"))
        .isNull();

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:28,代码来源:JCacheConfigurationTest.java

示例8: testEviction

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testEviction() {
    Properties properties =
        HazelcastCachingProvider.propertiesByLocation("classpath:my-hazelcast.xml");

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager(URI.create("my-cache-manager"),
                                                    null,
                                                    properties);

    Cache<String, String> cache = manager.getCache("with-eviction-cache",
                                                   String.class,
                                                   String.class);

    com.hazelcast.cache.ICache<String, String> icache =
        cache.unwrap(com.hazelcast.cache.ICache.class);
    com.hazelcast.config.CacheConfig config =
        icache.getConfiguration(com.hazelcast.config.CacheConfig.class);

    assertThat(config.getEvictionConfig().getSize())
        .isEqualTo(5);  // right

    IntStream.rangeClosed(1, 30).forEach(i -> cache.put("key" + i, "value" + i));

    int count = 0;
    for (Cache.Entry<String, String> entry : cache) {
        count++;
    }

    assertThat(count)
        .isGreaterThan(25);  // much larger than ENTRY_COUNT??

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:37,代码来源:JCacheConfigurationTest.java

示例9: testEvictionWithExpire

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testEvictionWithExpire() throws InterruptedException {
    Properties properties =
        HazelcastCachingProvider.propertiesByLocation("classpath:my-hazelcast.xml");

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager(URI.create("my-cache-manager"),
                                                    null,
                                                    properties);
    Cache<String, String> cache = manager.getCache("with-expire-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 30).forEach(i -> cache.put("key" + i, "value" + i));

    TimeUnit.SECONDS.sleep(3);

    cache.get("key1");
    cache.get("key3");
    cache.get("key5");
    cache.get("key10");
    cache.get("key13");
    cache.get("key15");
    cache.get("key20");
    cache.get("key25");

    TimeUnit.SECONDS.sleep(3);

    int count = 0;
    for (Cache.Entry<String, String> entry : cache) {
        count++;
    }

    assertThat(count)
        .isLessThanOrEqualTo(8);

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:41,代码来源:JCacheConfigurationTest.java

示例10: testEviction

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testEviction() {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager();
    Cache<String, String> cache = manager.getCache("with-eviction-cache",
                                                   String.class,
                                                   String.class);

    com.hazelcast.cache.ICache<String, String> icache =
        cache.unwrap(com.hazelcast.cache.ICache.class);
    com.hazelcast.config.CacheConfig config =
        icache.getConfiguration(com.hazelcast.config.CacheConfig.class);

    assertThat(config.getEvictionConfig().getSize())
        .isEqualTo(5);  // right

    IntStream.rangeClosed(1, 30).forEach(i -> cache.put("key" + i, "value" + i));

    int count = 0;
    for (Cache.Entry<String, String> entry : cache) {
        count++;
    }

    assertThat(count)
        .isGreaterThan(25);  // much larger than ENTRY_COUNT??

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:31,代码来源:JCacheConfigurationTest.java

示例11: testExpire

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testExpire() throws InterruptedException {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager();
    Cache<String, String> cache = manager.getCache("with-expire-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 5).forEach(i -> cache.put("key" + i, "value" + i));

    TimeUnit.SECONDS.sleep(3);

    cache.get("key1");
    cache.get("key3");

    TimeUnit.SECONDS.sleep(3);

    assertThat(cache.get("key1"))
        .isEqualTo("value1");
    assertThat(cache.get("key3"))
        .isEqualTo("value3");
    assertThat(cache.get("key2"))
        .isNull();
    assertThat(cache.get("key4"))
        .isNull();

    TimeUnit.SECONDS.sleep(6);

    assertThat(cache.get("key1"))
        .isNull();
    assertThat(cache.get("key3"))
        .isNull();

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:38,代码来源:JCacheConfigurationTest.java

示例12: testEvictionWithExpire

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testEvictionWithExpire() throws InterruptedException {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager();
    Cache<String, String> cache = manager.getCache("with-expire-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 30).forEach(i -> cache.put("key" + i, "value" + i));

    TimeUnit.SECONDS.sleep(3);

    cache.get("key1");
    cache.get("key3");
    cache.get("key5");
    cache.get("key10");
    cache.get("key13");
    cache.get("key15");
    cache.get("key20");
    cache.get("key25");

    TimeUnit.SECONDS.sleep(3);

    int count = 0;
    for (Cache.Entry<String, String> entry : cache) {
        count++;
    }

    assertThat(count)
        .isLessThanOrEqualTo(8);

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:36,代码来源:JCacheConfigurationTest.java

示例13: closeCachingProvider

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void closeCachingProvider() {
  CachingProvider provider = Caching.getCachingProvider();

  ClassLoader loader1 = CLASS_LOADER;
  CacheManager manager1 = provider.getCacheManager(provider.getDefaultURI(), loader1, null);

  ClassLoader loader2 = new MyClassLoader(CLASS_LOADER);
  CacheManager manager2 = provider.getCacheManager(provider.getDefaultURI(), loader2, null);

  provider.close();

  assertNotSame(manager1, provider.getCacheManager(provider.getDefaultURI(), loader1, null));
  assertNotSame(manager2, provider.getCacheManager(provider.getDefaultURI(), loader2, null));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:16,代码来源:CachingProviderTest.java

示例14: closeClassLoader

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
/**
 * Attempt to close CacheManagers using URIs and/or ClassLoaders that don't
 * have associated CacheManagers.
 */
@Test
public void closeClassLoader() throws Exception {
  ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();

  CachingProvider provider = Caching.getCachingProvider(contextLoader);

  URI uri = provider.getDefaultURI();

  ClassLoader loader1 = new MyClassLoader(contextLoader);
  CacheManager manager1 = provider.getCacheManager(uri, loader1);

  ClassLoader loader2 = new MyClassLoader(contextLoader);
  CacheManager manager2 = provider.getCacheManager(uri, loader2);

  ClassLoader loader3 = new MyClassLoader(contextLoader);
  CacheManager manager3 = provider.getCacheManager(uri, loader3);

  provider.close(contextLoader);
  provider.close(provider.getDefaultURI(), contextLoader);
  provider.close(provider.getDefaultURI(), contextLoader);
  provider.close(provider.getDefaultURI(), contextLoader);

  assertSame(manager1, provider.getCacheManager(uri, loader1));
  assertSame(manager2, provider.getCacheManager(uri, loader2));
  assertSame(manager3, provider.getCacheManager(uri, loader3));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:31,代码来源:CachingProviderClassLoaderTest.java

示例15: testExpire

import javax.cache.spi.CachingProvider; //导入方法依赖的package包/类
@Test
public void testExpire() throws InterruptedException {
    Properties properties =
        HazelcastCachingProvider.propertiesByLocation("classpath:my-hazelcast.xml");

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager manager = provider.getCacheManager(URI.create("my-cache-manager"),
                                                    null,
                                                    properties);

    Cache<String, String> cache = manager.getCache("with-expire-cache",
                                                   String.class,
                                                   String.class);

    IntStream.rangeClosed(1, 5).forEach(i -> cache.put("key" + i, "value" + i));

    TimeUnit.SECONDS.sleep(3);

    cache.get("key1");
    cache.get("key3");

    TimeUnit.SECONDS.sleep(3);

    assertThat(cache.get("key1"))
        .isEqualTo("value1");
    assertThat(cache.get("key3"))
        .isEqualTo("value3");
    assertThat(cache.get("key2"))
        .isNull();
    assertThat(cache.get("key4"))
        .isNull();

    TimeUnit.SECONDS.sleep(6);

    assertThat(cache.get("key1"))
        .isNull();
    assertThat(cache.get("key3"))
        .isNull();

    cache.close();
    manager.close();
    provider.close();
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:44,代码来源:JCacheConfigurationTest.java


注:本文中的javax.cache.spi.CachingProvider.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。