/** * setTimeToLiveSeconds * * @param ttl */ public void setTimeToLiveSeconds(long ttl) { cacheConfiguration.setTimeToLiveSeconds(ttl); }
/** * Builder which sets the time to idle for an element before it expires. Is only used if the element is not eternal. * This default can be overridden in {@link net.sf.ehcache.Element} * <p> * This property can be modified dynamically while the cache is operating. * * @param timeToLiveSeconds the default amount of time to live for an element from its creation date * @return this configuration instance * @see #setTimeToLiveSeconds(long) */ public final CacheConfiguration timeToLiveSeconds(long timeToLiveSeconds) { setTimeToLiveSeconds(timeToLiveSeconds); return this; }
/** * {@inheritDoc} */ public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { Cache cache = this.cacheManager.getCache(region); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds); sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); } }
/** * {@inheritDoc} */ @Override public void setTimeToLiveSeconds(long ttl) { if (getTimeToLiveSeconds() != ttl) { try { cache.getCacheConfiguration().setTimeToLiveSeconds(ttl); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
/** * Sets whether elements are eternal. If eternal, timeouts are ignored and the element is never expired. False by default. * * @param eternal true for eternal */ public final void setEternal(boolean eternal) { checkDynamicChange(); isEternalValueConflictingWithTTIOrTTL(eternal, getTimeToLiveSeconds(), getTimeToIdleSeconds()); this.eternal = eternal; if (eternal) { setTimeToIdleSeconds(0); setTimeToLiveSeconds(0); } }
/** * setTimeToLiveSeconds * * @param ttl */ public void setTimeToLiveSeconds(long ttl) { cacheConfiguration.setTimeToLiveSeconds(ttl); }
/** * setTimeToLiveSeconds * * @param ttl */ public void setTimeToLiveSeconds(long ttl) { cacheConfiguration.setTimeToLiveSeconds(ttl); }
/** * setTimeToLiveSeconds * * @param ttl */ public void setTimeToLiveSeconds(long ttl) { cacheConfiguration.setTimeToLiveSeconds(ttl); }
/** * Sets the time to idle for an element before it expires. Is only used if the element is not * eternal. * * @param timeToLiveSeconds the default amount of time to live for an element from its creation * date */ public void setTimeToLiveSeconds(long timeToLiveSeconds) { cache.getCacheConfiguration().setTimeToLiveSeconds(timeToLiveSeconds); }
@Override public final boolean updateExpireAfterWrite(long expireAfter, @Nonnull TimeUnit timeUnit) { delegate.getCacheConfiguration().setTimeToLiveSeconds(timeUnit.toSeconds(expireAfter)); return true; }
/** * Sets the time to idle for an element before it expires. Is only used if the element is not eternal. * * @param timeToLiveSeconds the default amount of time to live for an element from its creation date */ public void setTimeToLiveSeconds(long timeToLiveSeconds) { cache.getCacheConfiguration().setTimeToLiveSeconds(timeToLiveSeconds); }
public void setTimeToLiveSeconds( int timeToLiveSeconds ) { if ( this.ehcache != null ) { this.ehcache.getCacheConfiguration().setTimeToLiveSeconds( timeToIdleSeconds ); } this.timeToLiveSeconds = timeToLiveSeconds; }
@Override public ToolkitCacheInternal<String, Serializable> getOrCreateToolkitCache(final Ehcache cache) { final String cacheManagerName = getCacheManagerName(cache); final String cacheName = cache.getName(); ToolkitCacheInternal<String, Serializable> toolkitCache = getOrCreateRegularToolkitCache( cacheManagerName, cacheName, cache.getCacheConfiguration()); if(wanUtil.isWanEnabledCache(cacheManagerName, cacheName)) { final boolean replicaCache = wanUtil.isCacheReplica(cacheManagerName, cacheName); final boolean bidirectional = wanUtil.isCacheBidirectional(cacheManagerName, cacheName); toolkitCache = createWanAwareToolkitCache(cacheManagerName, cacheName, toolkitCache, cache.getCacheConfiguration(), !replicaCache, bidirectional); if (replicaCache) { LOGGER.info("Pinning the Cache '{}' belonging to Cache Manager '{}' " + "and setting its TTI and TTL values to zero as it is a WAN Replica Cache. " + "This cache's capacity will be controlled by its Master cache.", cacheName, cacheManagerName); PinningConfiguration pinningConfiguration = new PinningConfiguration(); pinningConfiguration.setStore(PinningConfiguration.Store.INCACHE.toString()); cache.getCacheConfiguration().addPinning(pinningConfiguration); cache.getCacheConfiguration().setMaxEntriesInCache(0); cache.getCacheConfiguration().setTimeToLiveSeconds(0); cache.getCacheConfiguration().setTimeToIdleSeconds(0); } cache.getCacheConfiguration().freezeConfiguration(); wanWatchdog.watch((Watchable) toolkitCache); } return toolkitCache; }
/** * {@inheritDoc} */ public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { Cache cache = this.cacheManager.getCache(region); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds); sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); } }
/** * {@inheritDoc} */ public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { Cache cache = this.cacheManager.getCache(region); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds); sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); } }
/** * {@inheritDoc} */ public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { Cache cache = this.cacheManager.getCache(region); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds); sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); } }
/** * {@inheritDoc} */ public void setTimeToLiveSeconds(long ttl) { if (getTimeToLiveSeconds() != ttl) { try { cache.getCacheConfiguration().setTimeToLiveSeconds(ttl); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
/** * {@inheritDoc} */ @Override public void setTimeToLiveSeconds(long ttl) { if (getTimeToLiveSeconds() != ttl) { try { cache.getCacheConfiguration().setTimeToLiveSeconds(ttl); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
/** * {@inheritDoc} */ @Override public void setTimeToLiveSeconds(long ttl) { if (getTimeToLiveSeconds() != ttl) { try { cache.getCacheConfiguration().setTimeToLiveSeconds(ttl); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
@Bean(destroyMethod = "shutdown") public net.sf.ehcache.CacheManager ehCacheManager() { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName("restApiAuthTokenCache"); cacheConfiguration.setMemoryStoreEvictionPolicy("LRU"); cacheConfiguration.setMaxEntriesLocalHeap(0); // 0 = MAX cacheConfiguration.setTimeToLiveSeconds(14400); // 4 hours. cacheConfiguration.setEternal(false); net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration(); config.addCache(cacheConfiguration); return net.sf.ehcache.CacheManager.newInstance(config); }