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

Java ModifiedExpiryPolicy类代码示例

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

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



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

示例1: testCreateCacheWithModifiedExpiryPolicy

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
@Test
public void testCreateCacheWithModifiedExpiryPolicy()
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();

    configuration.setStoreByValue(false);
    configuration.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY));

    Cache cache = cacheManager.createCache("cache", configuration);

    CompleteConfiguration actualConfiguration =
        (CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);

    assertEquals(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY), actualConfiguration.getExpiryPolicyFactory());
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:18,代码来源:GuavaCacheManagerTest.java


示例2: cacheConfiguration

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的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: createCaches

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的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


示例4: validateConfiguration

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
private void validateConfiguration(CompleteConfiguration<?, ?> configuration)
{
    if (configuration.isStoreByValue())
    {
        throw new UnsupportedOperationException("Store by value is not supported in Guava!");
    }

    if (configuration.getExpiryPolicyFactory() == null)
    {
        throw new NullPointerException("Expiry policy factory cannot be null!");
    }

    ExpiryPolicy expiryPolicy = configuration.getExpiryPolicyFactory().create();

    if (!(expiryPolicy instanceof EternalExpiryPolicy)
        && !(expiryPolicy instanceof ModifiedExpiryPolicy)
        && !(expiryPolicy instanceof TouchedExpiryPolicy))
    {
        throw new UnsupportedOperationException("Invalid expiry policy configuration!");
    }

    if (configuration.isReadThrough() && configuration.getCacheLoaderFactory() == null)
    {
        throw new IllegalArgumentException("Invalid read through cache configuration!");
    }

    if (configuration.isWriteThrough() || configuration.getCacheWriterFactory() != null)
    {
        throw new UnsupportedOperationException("Invalid write through cache configuration!");
    }
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:32,代码来源:GuavaCacheManager.java


示例5: setup

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
@Override
protected void setup(Settings settings, CacheManager cacheManager) {

    // example items cache
    cacheManager.createCache(ITEMS_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_MINUTE))
            .setStatisticsEnabled(true)
            .setStoreByValue(true));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:10,代码来源:Caches.java


示例6: setup

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
@Override
protected void setup(Settings settings, CacheManager cacheManager) {

    // example items cache
    cacheManager.createCache(ITEMS_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_MINUTE))
            .setStatisticsEnabled(true)
            .setStoreByValue(true));

    // example employee cache
    cacheManager.createCache(EMPLOYEE_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_MINUTE))
            .setStatisticsEnabled(true)
            .setStoreByValue(true));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:16,代码来源:Caches.java


示例7: cacheWithExpiryPolicy

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
/**
 * @param maxInactiveInteval Interval to use in expiry policy.
 * @param cache Cache.
 * @param <T> Cached object type.
 * @return Cache with expiry policy if {@code maxInactiveInteval} greater than zero.
 */
private <T> IgniteCache<String, T> cacheWithExpiryPolicy(final int maxInactiveInteval,
    final IgniteCache<String, T> cache) {
    if (maxInactiveInteval > 0) {
        long ttl = maxInactiveInteval * 1000L;

        ExpiryPolicy plc = new ModifiedExpiryPolicy(new Duration(MILLISECONDS, ttl));

        return cache.withExpiryPolicy(plc);
    }

    return cache;
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:WebSessionFilter.java


示例8: applyx

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public IgniteInternalFuture<?> applyx(IgniteInternalCache<Object, Object> c, GridKernalContext ctx) {
    if (ttl != null && ttl > 0) {
        Duration duration = new Duration(MILLISECONDS, ttl);

        c = c.withExpiryPolicy(new ModifiedExpiryPolicy(duration));
    }

    return c.putIfAbsentAsync(key, val);
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:GridCacheCommandHandler.java


示例9: checkExpiredEvents

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
/**
 * @param ccfg Cache configuration.
 * @throws Exception If failed.
 */
private void checkExpiredEvents(CacheConfiguration<Object, Object> ccfg) throws Exception {
    IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg);

    try {
        evtCntr = new AtomicInteger();

        CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
            new ExpiredListenerFactory(),
            null,
            true,
            false
        );

        cache.registerCacheEntryListener(lsnrCfg);

        IgniteCache<Object, Object> expiryCache =
            cache.withExpiryPolicy(new ModifiedExpiryPolicy(new Duration(MILLISECONDS, 500)));

        expiryCache.put(1, 1);

        for (int i = 0; i < 10; i++)
            cache.get(i);

        boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
            @Override public boolean apply() {
                return evtCntr.get() > 0;
            }
        }, 5000);

        assertTrue(wait);

        U.sleep(100);

        assertEquals(1, evtCntr.get());
    }
    finally {
        ignite(0).destroyCache(cache.getName());
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:44,代码来源:IgniteCacheEntryListenerExpiredEventsTest.java


示例10: call

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Object call() throws Exception {
    IgniteCache cache = ignite.cache(cacheName);

    if (withExpiryPlc)
        cache = cache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create());

    Map vals = cache.getAll(keys);

    Collection<CacheEntry> entries = cache.getEntries(keys);

    assertEquals(vals.size(), entries.size());

    for (CacheEntry entry : entries) {
        Object val = vals.get(entry.getKey());

        assertEquals(val, entry.getValue());
    }

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


示例11: createFactory

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
@Override public Factory<? extends ExpiryPolicy> createFactory( Long seconds ) {
  return ModifiedExpiryPolicy.factoryOf( getDuration( seconds ) );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:4,代码来源:Constants.java


示例12: expire_whenCreated_ModifiedExpiryPolicy

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
@Test
public void expire_whenCreated_ModifiedExpiryPolicy() {
  // since TouchedExpiryPolicy uses same duration for created and accessed, this policy will work same as
  // CreatedExpiryPolicy for this test.
  expire_whenCreated(FactoryBuilder.factoryOf(new ModifiedExpiryPolicy(Duration.ZERO)));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:7,代码来源:CacheExpiryTest.java


示例13: testCreateUpdate0

import javax.cache.expiry.ModifiedExpiryPolicy; //导入依赖的package包/类
/**
 * @throws Exception if failed.
 */
public void testCreateUpdate0() throws Exception {
    startGrids(1);

    long ttl = 60L;

    final String key = "key1";

    final IgniteCache<String, String> cache = jcache();

    for (int i = 0; i < 1000; i++) {
        final IgniteCache<String, String> cache0 = cache.withExpiryPolicy(new ModifiedExpiryPolicy(new Duration(TimeUnit.HOURS, ttl)));

        cache0.put(key, key);

        info("PUT DONE");
    }

    long pSize = grid(0).context().cache().internalCache(DEFAULT_CACHE_NAME).context().ttl().pendingSize();

    assertTrue("Too many pending entries: " + pSize, pSize <= 1);

    cache.remove(key);

    pSize = grid(0).context().cache().internalCache(DEFAULT_CACHE_NAME).context().ttl().pendingSize();

    assertEquals(0, pSize);
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:IgniteCacheExpiryPolicyAbstractTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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