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


Java NearCacheConfig.setTimeToLiveSeconds方法代码示例

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


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

示例1: testReadFromCache

import com.hazelcast.config.NearCacheConfig; //导入方法依赖的package包/类
@Test
public void testReadFromCache() {
    System.setProperty("hazelcast.client.near.cache.enabled", "true");
    Config config = new Config();
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setMaxSize(1000);
    nearCacheConfig.setMaxIdleSeconds(10);
    nearCacheConfig.setTimeToLiveSeconds(20);
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
    String mapName = "testReadFromCache";
    IMap<String, String> mapH = h.getMap(mapName);
    mapH.put("a", "a");
    HazelcastClient client = HazelcastClient.newHazelcastClient(new ClientConfig());
    Map<Object, Object> mapC = client.getMap(mapName);

    assertEquals("a", mapC.get("a"));
    int hit = mapH.getMapEntry("a").getHits();
    mapC.get("a");
    assertEquals(mapH.getMapEntry("a").getHits(), hit);
    for (int i = 0; i < 100; i++) {
        mapC.get("a");
    }
    assertEquals(mapH.getMapEntry("a").getHits(), hit);
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:26,代码来源:ClientMapGuavaCacheTest.java

示例2: testNoNearCacheConfig

import com.hazelcast.config.NearCacheConfig; //导入方法依赖的package包/类
@Test
public void testNoNearCacheConfig() {
    System.setProperty("hazelcast.client.near.cache.enabled", "false");
    Config config = new Config();
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setMaxSize(1000);
    nearCacheConfig.setMaxIdleSeconds(10);
    nearCacheConfig.setTimeToLiveSeconds(20);
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
    String mapName = "testReadFromCache";
    IMap<String, String> mapH = h.getMap(mapName);
    mapH.put("a", "a");
    HazelcastClient client = HazelcastClient.newHazelcastClient(new ClientConfig());
    Map<Object, Object> mapC = client.getMap(mapName);

    assertEquals("a", mapC.get("a"));
    int hit = mapH.getMapEntry("a").getHits();
    mapC.get("a");
    assertEquals(mapH.getMapEntry("a").getHits(), ++hit);
    for (int i = 0; i < 100; i++) {
        mapC.get("a");
    }
    assertEquals(mapH.getMapEntry("a").getHits(), hit + 100);
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:26,代码来源:ClientMapGuavaCacheTest.java

示例3: setupConfig

import com.hazelcast.config.NearCacheConfig; //导入方法依赖的package包/类
public static void setupConfig(HazelcastConnection hazelcastConnection) {
    MapConfig mapConfig = hazelcastConnection.getHazelcastConfig().getMapConfig(NAME_PREFIX + "*");
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setTimeToLiveSeconds(10);
    mapConfig.setMaxIdleSeconds(10);
    mapConfig.setBackupCount(0);
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setTimeToLiveSeconds(10);
    nearCacheConfig.setInvalidateOnChange(true);
    nearCacheConfig.setMaxIdleSeconds(10);
    mapConfig.setNearCacheConfig(nearCacheConfig);
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:13,代码来源:DistributedCache.java


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