本文整理了Java中com.hazelcast.config.Config.addCacheConfig()
方法的一些代码示例,展示了Config.addCacheConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.addCacheConfig()
方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:addCacheConfig
[英]Adds the cache configuration. The configuration is saved under the config name, which may be a pattern with which the configuration will be obtained in the future.
[中]添加缓存配置。配置保存在配置名称下,该名称可能是将来获取配置的模式。
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
Config config = new Config().addCacheConfig(createCacheSimpleConfig(BASE_CACHE_NAME + "_1"));
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
CachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
// ICacheManager is Hazelcast-specific interface, not to be confused with JCache's CacheManager.
// An instance of the ICacheManager can be obtained from a HazelcastInstance and used to get
// a reference to an existing cache.
ICacheManager hazelcastCacheManager = instance.getCacheManager();
ICache cache1 = hazelcastCacheManager.getCache(BASE_CACHE_NAME + "_1");
ICache cache2a = (ICache) cacheManager.createCache(BASE_CACHE_NAME + "_2", new CacheConfig(BASE_CACHE_NAME + "_2"));
ICache cache2b = hazelcastCacheManager.getCache(BASE_CACHE_NAME + "_2");
System.out.println("cache2a (through CacheManager) == cache2b (through HazelcastInstance): " + (cache2a == cache2b));
System.out.println("Distributed objects before destroy:");
for (DistributedObject distributedObject : instance.getDistributedObjects()) {
System.out.println("\t- Distributed object with name " + distributedObject.getName());
}
cache1.destroy();
cache2a.destroy();
System.out.println("Distributed objects after destroy:");
for (DistributedObject distributedObject : instance.getDistributedObjects()) {
System.out.println("\tDistributed object with name " + distributedObject.getName());
}
instance.shutdown();
}
代码示例来源:origin: hazelcast/hazelcast-jet
throw new InvalidConfigurationException(e.getMessage());
config.addCacheConfig(cacheConfig);
代码示例来源:origin: com.hazelcast/hazelcast-all
throw new InvalidConfigurationException(e.getMessage());
config.addCacheConfig(cacheConfig);
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static Config getConfig() {
Config config = new Config();
config.addCacheConfig(new CacheSimpleConfig().setName(CACHE_NAME));
// Add an event journal config for cache which has custom capacity of 1000 (default 10_000)
// and time to live seconds as 10 seconds (default 0 which means infinite)
config.addEventJournalConfig(new EventJournalConfig().setEnabled(true)
.setCacheName(CACHE_NAME)
.setCapacity(1000)
.setTimeToLiveSeconds(10));
return config;
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static JetConfig getJetConfig() {
JetConfig cfg = new JetConfig();
cfg.getHazelcastConfig().addCacheConfig(new CacheSimpleConfig().setName(CACHE_NAME));
// Add an event journal config for cache which has custom capacity of 1000 (default 10_000)
// and time to live seconds as 10 seconds (default 0 which means infinite)
cfg.getHazelcastConfig()
.getCacheEventJournalConfig(CACHE_NAME)
.setEnabled(true)
.setCapacity(1000)
.setTimeToLiveSeconds(10);
return cfg;
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
.addCacheConfig(new CacheSimpleConfig().setName(SOURCE_NAME))
.addCacheConfig(new CacheSimpleConfig().setName(SINK_NAME));
内容来源于网络,如有侵权,请联系作者删除!