• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HazelcastCachingProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.hazelcast.cache.HazelcastCachingProvider的典型用法代码示例。如果您正苦于以下问题:Java HazelcastCachingProvider类的具体用法?Java HazelcastCachingProvider怎么用?Java HazelcastCachingProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HazelcastCachingProvider类属于com.hazelcast.cache包,在下文中一共展示了HazelcastCachingProvider类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initialize

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
void initialize(RepositoryImpl repo) {
	this.repo = repo;
	execService = repo.getHazelcastClient().getExecutorService(PN_XDM_SCHEMA_POOL);
	//resCache = repo.getHazelcastClient().getMap(CN_XDM_RESULT);
	xqCache = repo.getHazelcastClient().getReplicatedMap(CN_XDM_QUERY);
	
       CachingProvider cachingProvider = Caching.getCachingProvider();
       // retrieve the javax.cache.CacheManager
       try {
		URI uri = new URI("hzClient");
		Properties props = HazelcastCachingProvider.propertiesByInstanceName(repo.getHazelcastClient().getName());
        CacheManager cacheManager = cachingProvider.getCacheManager(uri, null, props);
        resCache = cacheManager.getCache(CN_XDM_RESULT, Long.class, XDMResults.class); 
	} catch (URISyntaxException ex) {
		logger.error("initialize.error;", ex);
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:QueryManagementImpl.java


示例2: jCacheCacheManager

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Bean
public javax.cache.CacheManager jCacheCacheManager() {
	javax.cache.CacheManager cacheManager = Caching
			.getCachingProvider(HazelcastCachingProvider.class.getName())
			.getCacheManager();
	MutableConfiguration<Object, Object> config = new MutableConfiguration<Object, Object>();
	config.setStatisticsEnabled(true);
	cacheManager.createCache("books", config);
	cacheManager.createCache("speakers", config);
	return cacheManager;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:CacheStatisticsAutoConfigurationTests.java


示例3: hazelcastAsJCacheWithCaches

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void hazelcastAsJCacheWithCaches() {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	try {
		load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
				"spring.cache.jcache.provider=" + cachingProviderFqn,
				"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
		JCacheCacheManager cacheManager = validateCacheManager(
				JCacheCacheManager.class);
		assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
	}
	finally {
		Caching.getCachingProvider(cachingProviderFqn).close();
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:CacheAutoConfigurationTests.java


示例4: hazelcastAsJCacheWithConfig

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void hazelcastAsJCacheWithConfig() throws IOException {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	String configLocation = "org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml";
	load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
			"spring.cache.jcache.provider=" + cachingProviderFqn,
			"spring.cache.jcache.config=" + configLocation);
	JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);

	Resource configResource = new ClassPathResource(configLocation);
	assertThat(cacheManager.getCacheManager().getURI())
			.isEqualTo(configResource.getURI());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:CacheAutoConfigurationTests.java


示例5: jCacheCacheWithCachesAndCustomizer

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void jCacheCacheWithCachesAndCustomizer() {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache",
			"spring.cache.jcache.provider=" + cachingProviderFqn,
			"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
	JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
	// see customizer
	assertThat(cacheManager.getCacheNames()).containsOnly("foo", "custom1");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:CacheAutoConfigurationTests.java


示例6: hazelcastAsJCacheWithCaches

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void hazelcastAsJCacheWithCaches() {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
			"spring.cache.jcache.provider=" + cachingProviderFqn,
			"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
	JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
	assertThat(cacheManager.getCacheNames(), hasSize(2));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:11,代码来源:CacheAutoConfigurationTests.java


示例7: hazelcastAsJCacheWithConfig

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void hazelcastAsJCacheWithConfig() throws IOException {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	String configLocation = "org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml";
	load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
			"spring.cache.jcache.provider=" + cachingProviderFqn,
			"spring.cache.jcache.config=" + configLocation);
	JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);

	Resource configResource = new ClassPathResource(configLocation);
	assertThat(cacheManager.getCacheManager().getURI(),
			equalTo(configResource.getURI()));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:14,代码来源:CacheAutoConfigurationTests.java


示例8: jCacheCacheWithCachesAndCustomizer

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的package包/类
@Test
public void jCacheCacheWithCachesAndCustomizer() {
	String cachingProviderFqn = HazelcastCachingProvider.class.getName();
	load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache",
			"spring.cache.jcache.provider=" + cachingProviderFqn,
			"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
	JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "custom1")); // see
	// customizer
	assertThat(cacheManager.getCacheNames(), hasSize(2));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:12,代码来源:CacheAutoConfigurationTests.java


示例9: testSimpleJCache

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的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


示例10: testEviction

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的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


示例11: testEvictionWithExpire

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的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


示例12: testExpire

import com.hazelcast.cache.HazelcastCachingProvider; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SecurityProtocol类代码示例发布时间:2022-05-22
下一篇:
Java DataChangeScope类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap