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


Java CreatedExpiryPolicy.factoryOf方法代码示例

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


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

示例1: configure

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
@Override
public void configure(Binder binder) {

    Factory<ExpiryPolicy> _100ms = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 100));
    Configuration<Long, Long> myCache2 = new MutableConfiguration<Long, Long>()
            .setTypes(Long.class, Long.class)
            .setExpiryPolicyFactory(_100ms)
            .addCacheEntryListenerConfiguration(new MyCache2EntryListenerConfiguration());

    //contribute the cache into BQ
    JCacheModule.extend(binder).setConfiguration("myCache2", myCache2);

    BQCoreModule.extend(binder).addCommand(DemoEhcacheCommand.class);
}
 
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:15,代码来源:Application.java

示例2: testContributedConfig

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
@Test
public void testContributedConfig() throws InterruptedException {

    Factory<ExpiryPolicy> _100ms = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 100));
    Configuration<Long, Long> boundConfig = new MutableConfiguration<Long, Long>()
            .setTypes(Long.class, Long.class)
            .setExpiryPolicyFactory(_100ms);

    BQRuntime runtime = testFactory.app()
            .autoLoadModules()
            .module(b -> JCacheModule.extend(b).setConfiguration("fromconfig", boundConfig))
            .createRuntime();

    CacheManager cm = runtime.getInstance(CacheManager.class);

    // test loaded caches

    Set<String> names = new HashSet<>();
    cm.getCacheNames().forEach(names::add);

    assertEquals(new HashSet<String>(asList("fromconfig")), names);

    // test cache config
    Cache<Long, Long> cache = cm.getCache("fromconfig", Long.class, Long.class);
    assertNotNull(cache);

    cache.put(5l, 10l);

    assertEquals(Long.valueOf(10), cache.get(5l));
    Thread.sleep(101);

    assertNull(cache.get(5l));
}
 
开发者ID:bootique,项目名称:bootique-jcache,代码行数:34,代码来源:JCacheModuleIT.java

示例3: testContributedAndXmlConfig

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
@Test
public void testContributedAndXmlConfig() throws InterruptedException {

    Factory<ExpiryPolicy> _100ms = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 100));
    Configuration<Long, Long> boundConfig = new MutableConfiguration<Long, Long>()
            .setTypes(Long.class, Long.class)
            .setExpiryPolicyFactory(_100ms);

    BQRuntime runtime = testFactory.app("-c", Objects.requireNonNull("classpath:ehcache2.yml"))
            .autoLoadModules()
            .module(b -> JCacheModule.extend(b).setConfiguration("fromconfig", boundConfig))
            .createRuntime();

    CacheManager cm = runtime.getInstance(CacheManager.class);

    // test loaded caches

    Set<String> names = new HashSet<>();
    cm.getCacheNames().forEach(names::add);

    assertEquals(new HashSet<String>(asList("fromxml", "fromconfig")), names);

    // test cache config
    Cache<Long, Long> cache = cm.getCache("fromconfig", Long.class, Long.class);
    assertNotNull(cache);

    cache.put(5l, 10l);

    assertEquals(Long.valueOf(10), cache.get(5l));
    Thread.sleep(101);

    assertNull(cache.get(5l));
}
 
开发者ID:bootique,项目名称:bootique-jcache,代码行数:34,代码来源:JCacheModuleIT.java

示例4: testZeroOnCreate

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testZeroOnCreate() throws Exception {
    factory = CreatedExpiryPolicy.factoryOf(Duration.ZERO);

    startGrids();

    for (final Integer key : keys()) {
        log.info("Test zero duration on create, key: " + key);

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

示例5: createFactory

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

示例6: testNearExpiresOnClient

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
/**
 * Put entry to server node and check how its expires in client NearCache.
 *
 * @throws Exception If failed.
 */
public void testNearExpiresOnClient() throws Exception {
    if (cacheMode() != PARTITIONED)
        return;

    factory = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 2));

    nearCache = true;

    startGrids();

    IgniteConfiguration clientCfg = getConfiguration("client").setClientMode(true);

    ((TcpDiscoverySpi)clientCfg.getDiscoverySpi()).setForceServerMode(false);

    Ignite client = startGrid("client", clientCfg);

    IgniteCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME);

    Integer key = 1;

    // Put on server node.
    jcache(0).put(key, 1);

    // Make entry cached in client NearCache.
    assertEquals(1, cache.get(key));

    assertEquals(1, cache.localPeek(key, CachePeekMode.NEAR));

    waitExpired(key);

    // Check client NearCache.
    assertNull(cache.localPeek(key, CachePeekMode.NEAR));
}
 
开发者ID:apache,项目名称:ignite,代码行数:39,代码来源:IgniteCacheExpiryPolicyAbstractTest.java

示例7: testNearExpiresWithCacheStore

import javax.cache.expiry.CreatedExpiryPolicy; //导入方法依赖的package包/类
/**
     * @throws Exception If failed.
     */
    public void testNearExpiresWithCacheStore() throws Exception {
        if(cacheMode() != PARTITIONED)
            return;

        factory = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1));

        nearCache = true;

        startGridsMultiThreaded(gridCount());

        IgniteConfiguration clientCfg = getConfiguration("client").setClientMode(true);

        ((TcpDiscoverySpi)clientCfg.getDiscoverySpi()).setForceServerMode(false);

        Ignite client = startGrid("client", clientCfg);

        CacheConfiguration ccfg = cacheConfiguration("testCache");

        ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class));
//        ccfg.setExpiryPolicyFactory( CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));

        IgniteCache<Object, Object> cache = client.getOrCreateCache(ccfg);

        Integer key = 1;

        cache.put(key, 1);

        // Make entry cached in client NearCache.
        assertEquals(1, cache.get(key));

        assertEquals(1, cache.localPeek(key, CachePeekMode.NEAR));

        waitExpired(key);

        for(int i = 0; i < gridCount(); i++)
            assertNull(jcache(i).localPeek(key, CachePeekMode.BACKUP, CachePeekMode.PRIMARY));

        assertEquals(null, cache.get(key));
    }
 
开发者ID:apache,项目名称:ignite,代码行数:43,代码来源:IgniteCacheExpiryPolicyAbstractTest.java


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