Class CreatedExpiryPolicy
- java.lang.Object
-
- javax.cache.expiry.CreatedExpiryPolicy
-
- All Implemented Interfaces:
java.io.Serializable,ExpiryPolicy
public final class CreatedExpiryPolicy extends java.lang.Object implements ExpiryPolicy, java.io.Serializable
AnExpiryPolicythat defines the expiryDurationof a Cache Entry based on when it was created. An update does not reset the expiry time.- Since:
- 1.0
- See Also:
ExpiryPolicy, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DurationexpiryDurationTheDurationa Cache Entry should be available before it expires.static longserialVersionUIDThe serialVersionUID required forSerializable.
-
Constructor Summary
Constructors Constructor Description CreatedExpiryPolicy(Duration expiryDuration)Constructs anCreatedExpiryPolicyExpiryPolicy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)static Factory<ExpiryPolicy>factoryOf(Duration duration)Obtains aFactoryfor a CreatedExpiryPolicy.DurationgetExpiryForAccess()Gets theDurationbefore an accessed Cache.Entry is considered expired.DurationgetExpiryForCreation()Gets theDurationbefore a newly created Cache.Entry is considered expired.DurationgetExpiryForUpdate()Gets theDurationbefore an updated Cache.Entry is considered expired.inthashCode()
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
The serialVersionUID required forSerializable.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CreatedExpiryPolicy
public CreatedExpiryPolicy(Duration expiryDuration)
Constructs anCreatedExpiryPolicyExpiryPolicy.- Parameters:
expiryDuration- theDurationa Cache Entry should exist be before it expires after being modified
-
-
Method Detail
-
factoryOf
public static Factory<ExpiryPolicy> factoryOf(Duration duration)
Obtains aFactoryfor a CreatedExpiryPolicy.- Parameters:
duration- The expiry duration- Returns:
- a
Factoryfor a CreatedExpiryPolicy.
-
getExpiryForCreation
public Duration getExpiryForCreation()
Gets theDurationbefore a newly created Cache.Entry is considered expired.This method is called by a caching implementation after a Cache.Entry is created, but before a Cache.Entry is added to a cache, to determine the
Durationbefore an entry expires. If aDuration.ZEROis returned the new Cache.Entry is considered to be already expired and will not be added to the Cache.Should an exception occur while determining the Duration, an implementation specific default
Durationwill be used.- Specified by:
getExpiryForCreationin interfaceExpiryPolicy- Returns:
- the new
Durationbefore a created entry expires
-
getExpiryForAccess
public Duration getExpiryForAccess()
Gets theDurationbefore an accessed Cache.Entry is considered expired.This method is called by a caching implementation after a Cache.Entry is accessed to determine the
Durationbefore an entry expires. If aDuration.ZEROis returned a Cache.Entry will be considered immediately expired. Returningnullwill result in no change to the previously understood expiryDuration.Should an exception occur while determining the Duration, an implementation specific default Duration will be used.
- Specified by:
getExpiryForAccessin interfaceExpiryPolicy- Returns:
- the new
Durationbefore an accessed entry expires
-
getExpiryForUpdate
public Duration getExpiryForUpdate()
Gets theDurationbefore an updated Cache.Entry is considered expired.This method is called by the caching implementation after a Cache.Entry is updated to determine the
Durationbefore the updated entry expires. If aDuration.ZEROis returned a Cache.Entry is considered immediately expired. Returningnullwill result in no change to the previously understood expiryDuration.Should an exception occur while determining the Duration, an implementation specific default Duration will be used.
- Specified by:
getExpiryForUpdatein interfaceExpiryPolicy- Returns:
- the new
Durationbefore an updated entry expires
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
-