Terracotta 10.5 | 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 predefined time-to-live one, configured with the required Duration.

Copyright © 2010-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.