Interface CacheConfigurationBuilder
-
public interface CacheConfigurationBuilder
A Builder to specify configuration forCache
regions. This is usually used while building a CacheManager via theCacheManagerBuilder
. CacheConfigurationBuilders can be constructed with theCaches
utility class. For example:Caches.named("cacheRegionNameHere") .
orwithTimeToLive(1, TimeUnit.DAYS)
.withTimeToIdle(2, TimeUnit.HOURS)
;Caches.forResource(Account.class) .
withTimeToLive(1, TimeUnit.DAYS)
.withTimeToIdle(2, TimeUnit.HOURS)
;
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CacheConfigurationBuilder
withTimeToIdle(long tti, java.util.concurrent.TimeUnit ttiTimeUnit)
Sets the associatedCache
region's entry Time to Idle (TTI).CacheConfigurationBuilder
withTimeToLive(long ttl, java.util.concurrent.TimeUnit ttlTimeUnit)
Sets the associatedCache
region's entry Time to Live (TTL).
-
-
-
Method Detail
-
withTimeToLive
CacheConfigurationBuilder withTimeToLive(long ttl, java.util.concurrent.TimeUnit ttlTimeUnit)
Sets the associatedCache
region's entry Time to Live (TTL).Time to Live is the amount of time a cache entry may exist after first being created before it will expire and no longer be available. If a cache entry ever becomes older than this amount of time (regardless of how often it is accessed), it will be removed from the cache as soon as possible.
If this value is not configured, it is assumed that the Cache's entries could potentially live indefinitely. Note however that entries can still be expunged due to other conditions (e.g. memory constraints, Time to Idle setting, etc).
Usage
...withTimeToLive(30, TimeUnit.MINUTES)... ...withTimeToLive(1, TimeUnit.HOURS)...
- Parameters:
ttl
- Time To Live scalar valuettlTimeUnit
- Time to Live unit of time- Returns:
- the associated
Cache
region's entry Time to Live (TTL).
-
withTimeToIdle
CacheConfigurationBuilder withTimeToIdle(long tti, java.util.concurrent.TimeUnit ttiTimeUnit)
Sets the associatedCache
region's entry Time to Idle (TTI).Time to Idle is the amount of time a cache entry may be idle (unused / not accessed) before it will expire and no longer be available. If a cache entry is not accessed at all after this amount of time, it will be removed from the cache as soon as possible.
If this value is not configured, it is assumed that the Cache's entries could potentially live indefinitely. Note however that entries can still be expunged due to other conditions (e.g. memory constraints, Time to Live setting, etc).
Usage
...withTimeToIdle(30, TimeUnit.MINUTES)... ...withTimeToIdle(1, TimeUnit.HOURS)...
- Parameters:
tti
- Time To Idle scalar valuettiTimeUnit
- Time to Idle unit of time- Returns:
- the associated
Cache
region's entry Time to Idle (TTI).
-
-