Ehcache API Developer Guide : Creating and Configuring a CacheManager Using Java : Data Freshness
Data Freshness
In Ehcache, data freshness is controlled through Expiry. The following example illustrates how to configure a time-to-live expiry.

CacheConfiguration<Long, String> cacheConfiguration =
CacheConfigurationBuilder.newCacheConfigurationBuilder(
Long.class, String.class, ResourcePoolsBuilder.heap(100)) // <1>
.withExpiry(Expirations.timeToLiveExpiration( // <2>
Duration.of(20, TimeUnit.SECONDS)))
.build();
1. Expiry is configured at the cache level, so start by defining a cache configuration,
2. then add to it an Expiry, here using the predefinedtime-to-live one, configured with the requiredDuration.
Copyright © 2010-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback