Java Code Examples for javax.cache.expiry.Duration#ETERNAL

The following examples show how to use javax.cache.expiry.Duration#ETERNAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheExpiryTest.java    From cache2k with Apache License 2.0 6 votes vote down vote up
@Test
public void testCacheStatisticsRemoveAllNoneExpired() throws Exception {

  ExpiryPolicy policy = new CreatedExpiryPolicy(Duration.ETERNAL);
  expiryPolicyServer.setExpiryPolicy(policy);

  MutableConfiguration<Integer, Integer> config = new MutableConfiguration<>();
  config.setExpiryPolicyFactory(FactoryBuilder.factoryOf(expiryPolicyClient))
      .setStatisticsEnabled(true);
  Cache<Integer, Integer> cache = getCacheManager().createCache(getTestCacheName(), config);
  for (int i = 0; i < 100; i++) {
    cache.put(i, i+100);
  }
  cache.removeAll();
  assertEquals(100L, lookupManagementAttribute(cache, CacheStatistics, "CachePuts"));
  assertEquals(100L, lookupManagementAttribute(cache, CacheStatistics, "CacheRemovals"));
}
 
Example 2
Source File: CountingExpiryPolicy.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Duration getExpiryForCreation() {
    
    creationCount.incrementAndGet();
    return Duration.ETERNAL;
}
 
Example 3
Source File: TypesafeConfigurator.java    From caffeine with Apache License 2.0 5 votes vote down vote up
/** Returns the duration for the expiration time. */
private @Nullable Duration getDurationFor(String path) {
  if (!isSet(path)) {
    return null;
  }
  if (merged.getString(path).equalsIgnoreCase("eternal")) {
    return Duration.ETERNAL;
  }
  long millis = merged.getDuration(path, MILLISECONDS);
  return new Duration(MILLISECONDS, millis);
}
 
Example 4
Source File: CacheLoaderWithExpiryTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Override
public Duration getExpiryForCreation() {
  return Duration.ETERNAL;
}
 
Example 5
Source File: CacheLoaderWithExpiryTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Override
public Duration getExpiryForUpdate() {
  return Duration.ETERNAL;
}
 
Example 6
Source File: CacheExpiryTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Duration getExpiryForCreation() {
  creationCount.incrementAndGet();
  return Duration.ETERNAL;
}