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


Java CacheConfiguration.setExpiryPolicyFactory方法代码示例

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


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

示例1: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName(CACHE_NAME);
    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 10)));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:ScanQueryOffheapExpiryPolicySelfTest.java

示例2: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param atomicityMode Atomicity mode.
 * @param heapCache Heap cache flag.
 * @param expiryPlc Expiry policy flag.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode,
    boolean heapCache,
    boolean expiryPlc) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setOnheapCacheEnabled(heapCache);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setName("testCache");

    if (expiryPlc)
        ccfg.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES));

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteCacheNoSyncForGetTest.java

示例3: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<String, Long> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setReadFromBackup(true);
    ccfg.setCopyOnRead(false);
    ccfg.setName(THROTTLES_CACHE_NAME);

    Duration expiryDuration = new Duration(TimeUnit.MINUTES, 1);

    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
    ccfg.setReadThrough(false);
    ccfg.setWriteThrough(true);

    ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(new TestCacheStore()));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:IgniteCacheWriteBehindNoUpdateSelfTest.java

示例4: createCaches

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
@Before
public void createCaches() {
    CacheConfiguration configuration = new CacheConfiguration<>();
    ModifiedExpiryPolicy expiryPolicy = new ModifiedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, 100));
    configuration.setExpiryPolicyFactory(FactoryBuilder.factoryOf(expiryPolicy));

    createCache(firstCache, TRANSACTIONAL, PARTITIONED, false, 0, configuration);
    createCache(secondCache, TRANSACTIONAL, PARTITIONED, false, 0, configuration);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:11,代码来源:ExpiryPolicyTest.java

示例5: IgniteCache

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
public IgniteCache(String name, long maxSize, long maxLifetime) {
	this.name = name;
	this.maxCacheSize = maxSize;
	this.maxLifetime = maxLifetime;
	CacheConfiguration<K, V> config = new CacheConfiguration<K, V>();
	config.setName(name);
	config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, maxLifetime)));
    map = IgniteInstance.getInstance().getIgnite().getOrCreateCache(config);
}
 
开发者ID:mini188,项目名称:j2cache,代码行数:10,代码来源:IgniteCache.java

示例6: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);

    if (nearCache)
        cfg.setNearConfiguration(new NearCacheConfiguration());

    cfg.setExpiryPolicyFactory(factory);

    if (disableEagerTtl)
        cfg.setEagerTtl(false);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:IgniteCacheExpiryPolicyAbstractTest.java

示例7: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setExpiryPolicyFactory(new TestExpiryPolicyFactory());

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:IgniteCacheExpiryPolicyWithStoreAbstractTest.java

示例8: wordCache

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Configure streaming cache.
 */
public static CacheConfiguration<AffinityUuid, String> wordCache() {
    CacheConfiguration<AffinityUuid, String> cfg = new CacheConfiguration<>("words");

    // Index all words streamed into cache.
    cfg.setIndexedTypes(AffinityUuid.class, String.class);

    // Sliding window of 1 seconds.
    cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 1))));

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:CacheConfig.java

示例9: igniteConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Ignite configuration ignite configuration.
 *
 * @return the ignite configuration
 */
@RefreshScope
@Bean
public IgniteConfiguration igniteConfiguration() {
    final IgniteProperties ignite = casProperties.getTicket().getRegistry().getIgnite();

    final IgniteConfiguration config = new IgniteConfiguration();
    final TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setHeartbeatFrequency(ignite.getHeartbeatFrequency());
    spi.setJoinTimeout(ignite.getJoinTimeout());

    if (!StringUtils.isEmpty(ignite.getLocalAddress())) {
        spi.setLocalAddress(ignite.getLocalAddress());
    }
    if (ignite.getLocalPort() != -1) {
        spi.setLocalPort(ignite.getLocalPort());
    }
    spi.setNetworkTimeout(ignite.getNetworkTimeout());
    spi.setSocketTimeout(ignite.getSocketTimeout());
    spi.setThreadPriority(ignite.getThreadPriority());
    spi.setForceServerMode(ignite.isForceServerMode());

    final TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
    finder.setAddresses(StringUtils.commaDelimitedListToSet(ignite.getIgniteAddresses()));
    spi.setIpFinder(finder);
    config.setDiscoverySpi(spi);

    final List<CacheConfiguration> configurations = new ArrayList<>();

    final CacheConfiguration ticketsCache = new CacheConfiguration();
    ticketsCache.setName(ignite.getTicketsCache().getCacheName());
    ticketsCache.setCacheMode(CacheMode.valueOf(ignite.getTicketsCache().getCacheMode()));
    ticketsCache.setAtomicityMode(CacheAtomicityMode.valueOf(ignite.getTicketsCache().getAtomicityMode()));
    ticketsCache.setWriteSynchronizationMode(
            CacheWriteSynchronizationMode.valueOf(
                    ignite.getTicketsCache().getWriteSynchronizationMode()));
    ticketsCache.setExpiryPolicyFactory(
            CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS,
                    casProperties.getTicket().getTgt().getMaxTimeToLiveInSeconds())));

    configurations.add(ticketsCache);

    config.setCacheConfiguration(configurations.toArray(new CacheConfiguration[]{}));

    return config;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:52,代码来源:IgniteTicketRegistryConfiguration.java

示例10: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(cacheMode);
    ccfg.setEagerTtl(true);
    ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100));
    ccfg.setOnheapCacheEnabled(true);
    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:GridCacheTtlManagerEvictionSelfTest.java

示例11: testReadThroughExpirePolicyConfigured

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @throws Exception if failed.
 */
public void testReadThroughExpirePolicyConfigured() throws Exception {
    Ignite ig = testedGrid();

    CacheConfiguration<Object, Object> cc = variationConfig("expireConfig");

    cc.setExpiryPolicyFactory(new ExpirePolicyFactory());

    IgniteCache<Object, Object> cache = ig.createCache(cc);

    try {
        for (int i = 0; i < KEYS; i++)
            cache.put(key(i), value(i));

        U.sleep(TIMEOUT);

        waitEmpty(cc.getName());

        for (int i = 0; i < KEYS; i++) {
            assertEquals(value(i), cache.get(key(i)));

            // Access expiry.
            cache.get(key(i));
        }

        U.sleep(TIMEOUT);

        waitEmpty(cc.getName());

        for (int i = 0; i < KEYS; i++)
            assertEquals(value(i), cache.get(key(i)));

        for (int i = 0; i < KEYS; i++) {
            assertEquals(value(i), cache.get(key(i)));

            // Update expiry.
            cache.put(key(i), value(i));
        }

        U.sleep(TIMEOUT);

        waitEmpty(cc.getName());

        for (int i = 0; i < KEYS; i++)
            assertEquals(value(i), cache.get(key(i)));
    }
    finally {
        destroyCacheSafe(ig, cc.getName());
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:53,代码来源:IgniteCacheReadThroughEvictionSelfTest.java


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