本文整理汇总了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;未经允许,请勿转载。 |
请发表评论