Package org.ehcache.config.builders
Class ExpiryPolicyBuilder<K,V>
java.lang.Object
org.ehcache.config.builders.ExpiryPolicyBuilder<K,V>
- All Implemented Interfaces:
org.ehcache.config.Builder<org.ehcache.expiry.ExpiryPolicy<K,V>>
public final class ExpiryPolicyBuilder<K,V>
extends Object
implements org.ehcache.config.Builder<org.ehcache.expiry.ExpiryPolicy<K,V>>
Builder and utilities for getting predefined
ExpiryPolicy instances.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionSet TTI since last access.<K2 extends K,V2 extends V>
ExpiryPolicyBuilder<K2,V2> access(BiFunction<K2, Supplier<? extends V2>, Duration> access) Set a function giving the TTI since last access.build()Builds an expiry policy instance.Set TTL since creation.<K2 extends K,V2 extends V>
ExpiryPolicyBuilder<K2,V2> create(BiFunction<K2, V2, Duration> create) Set a function giving the TTL since creation.static ExpiryPolicyBuilder<Object,Object> expiry()Fluent API for creating anExpiryPolicyinstance where you can specify constant values for creation, access and update time.Get anExpiryPolicyinstance for a non expiring (ie.timeToIdleExpiration(Duration timeToIdle) Get a time-to-idle (TTI)ExpiryPolicyinstance for the givenDuration.timeToLiveExpiration(Duration timeToLive) Get a time-to-live (TTL)ExpiryPolicyinstance for the givenDuration.Set TTL since last update.<K2 extends K,V2 extends V>
ExpiryPolicyBuilder<K2,V2> update(ExpiryPolicyBuilder.TriFunction<K2, Supplier<? extends V2>, V2, Duration> update) Set a function giving the TTL since last update.
-
Method Details
-
noExpiration
Get anExpiryPolicyinstance for a non expiring (ie. "eternal") cache.- Returns:
- the no expiry instance
-
timeToLiveExpiration
public static org.ehcache.expiry.ExpiryPolicy<Object,Object> timeToLiveExpiration(Duration timeToLive) Get a time-to-live (TTL)ExpiryPolicyinstance for the givenDuration.- Parameters:
timeToLive- the TTL duration- Returns:
- a TTL expiry
-
timeToIdleExpiration
public static org.ehcache.expiry.ExpiryPolicy<Object,Object> timeToIdleExpiration(Duration timeToIdle) Get a time-to-idle (TTI)ExpiryPolicyinstance for the givenDuration.- Parameters:
timeToIdle- the TTI duration- Returns:
- a TTI expiry
-
expiry
Fluent API for creating anExpiryPolicyinstance where you can specify constant values for creation, access and update time. Unspecified values will be set toINFINITEfor create andnullfor access and update, matching thenoExpiration()no expiration} expiry.- Returns:
- an
ExpiryPolicybuilder
-
create
Set TTL since creation.Note: Calling this method on a builder with an existing TTL since creation will override the previous value or function.
- Parameters:
create- TTL since creation- Returns:
- a new builder with the TTL since creation
-
create
public <K2 extends K,V2 extends V> ExpiryPolicyBuilder<K2,V2> create(BiFunction<K2, V2, Duration> create) Set a function giving the TTL since creation.Note: Calling this method on a builder with an existing TTL since creation will override the previous value or function.
- Parameters:
create- Function giving the TTL since creation- Returns:
- a new builder with the TTL creation calculation function
-
access
Set TTI since last access.Note: Calling this method on a builder with an existing TTI since last access will override the previous value or function.
- Parameters:
access- TTI since last access- Returns:
- a new builder with the TTI since last access
-
access
public <K2 extends K,V2 extends V> ExpiryPolicyBuilder<K2,V2> access(BiFunction<K2, Supplier<? extends V2>, Duration> access) Set a function giving the TTI since last access.Note: Calling this method on a builder with an existing TTI since last access will override the previous value or function.
- Parameters:
access- Function giving the TTI since last access- Returns:
- a new builder with the TTI since last access calculation function
-
update
Set TTL since last update.Note: Calling this method on a builder with an existing TTL since last access will override the previous value or function.
- Parameters:
update- TTL since last update- Returns:
- a new builder with the TTL since last update
-
update
public <K2 extends K,V2 extends V> ExpiryPolicyBuilder<K2,V2> update(ExpiryPolicyBuilder.TriFunction<K2, Supplier<? extends V2>, V2, Duration> update) Set a function giving the TTL since last update.Note: Calling this method on a builder with an existing TTL since last update will override the previous value or function.
- Parameters:
update- Function giving the TTL since last update- Returns:
- a new builder with the TTL since last update calculation function
-
build
Builds an expiry policy instance.- Specified by:
buildin interfaceorg.ehcache.config.Builder<K>- Returns:
- an
ExpiryPolicy
-