Package com.hazelcast.cache
Class HazelcastExpiryPolicy
java.lang.Object
com.hazelcast.cache.HazelcastExpiryPolicy
- All Implemented Interfaces:
- DataSerializable,- IdentifiedDataSerializable,- Serializable,- javax.cache.expiry.ExpiryPolicy
public class HazelcastExpiryPolicy
extends Object
implements javax.cache.expiry.ExpiryPolicy, IdentifiedDataSerializable, Serializable
Hazelcast provides overloads of the typical cache operations with a custom
 ExpiryPolicy parameter.
 This class provides a custom implementation of an ExpiryPolicy to
 react on all three types of policies:
 
- Create
- Access
- Update
Sample usage:
   ICache<Key, Value> unwrappedCache =  cache.unwrap( ICache.class );
   HazelcastExpiryPolicy customExpiry = new HazelcastExpiryPolicy(20, 30, 40, TimeUnit.SECONDS);
   unwrappedCache.put("key1", value, customExpiry );
 - Since:
- 3.3.1
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor to serialize/deserializeHazelcastExpiryPolicy(long createMillis, long accessMillis, long updateMillis) Constructs an expiry policy with provided values for creation, access and update in milliseconds.HazelcastExpiryPolicy(long createDurationAmount, long accessDurationAmount, long updateDurationAmount, TimeUnit timeUnit) Constructs an expiry policy with provided values for creation, access and update as well as aTimeUnitto convert those values to internally used time unites.HazelcastExpiryPolicy(javax.cache.expiry.Duration create, javax.cache.expiry.Duration access, javax.cache.expiry.Duration update) Constructs an expiry policy with provided values for creation, access and update by providing instances of theDurationclass.HazelcastExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy) Copy Constructor for an already existingExpiryPolicy.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanintReturns type identifier for this class.javax.cache.expiry.Durationjavax.cache.expiry.Durationjavax.cache.expiry.DurationintReturns DataSerializableFactory factory ID for this class.inthashCode()voidReads fields from the input streamtoString()voidWrites object fields to output stream
- 
Constructor Details- 
HazelcastExpiryPolicypublic HazelcastExpiryPolicy()Default constructor to serialize/deserialize
- 
HazelcastExpiryPolicypublic HazelcastExpiryPolicy(long createMillis, long accessMillis, long updateMillis) Constructs an expiry policy with provided values for creation, access and update in milliseconds.- Parameters:
- createMillis- expiry time in milliseconds after creation
- accessMillis- expiry time in milliseconds after last access
- updateMillis- expiry time in milliseconds after last update
 
- 
HazelcastExpiryPolicypublic HazelcastExpiryPolicy(long createDurationAmount, long accessDurationAmount, long updateDurationAmount, TimeUnit timeUnit) Constructs an expiry policy with provided values for creation, access and update as well as aTimeUnitto convert those values to internally used time unites.- Parameters:
- createDurationAmount- expiry time after creation
- accessDurationAmount- expiry time after last access
- updateDurationAmount- expiry time after last update
- timeUnit- time unit of the previous value parameters
 
- 
HazelcastExpiryPolicypublic HazelcastExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy) Copy Constructor for an already existingExpiryPolicy. Values are copied to the internal state as is.- Parameters:
- expiryPolicy- expiry policy to copy
 
- 
HazelcastExpiryPolicypublic HazelcastExpiryPolicy(javax.cache.expiry.Duration create, javax.cache.expiry.Duration access, javax.cache.expiry.Duration update) Constructs an expiry policy with provided values for creation, access and update by providing instances of theDurationclass.- Parameters:
- create- expiry duration after creation
- access- expiry duration after last access
- update- expiry duration after last update
 
 
- 
- 
Method Details- 
getExpiryForCreationpublic javax.cache.expiry.Duration getExpiryForCreation()- Specified by:
- getExpiryForCreationin interface- javax.cache.expiry.ExpiryPolicy
 
- 
getExpiryForAccesspublic javax.cache.expiry.Duration getExpiryForAccess()- Specified by:
- getExpiryForAccessin interface- javax.cache.expiry.ExpiryPolicy
 
- 
getExpiryForUpdatepublic javax.cache.expiry.Duration getExpiryForUpdate()- Specified by:
- getExpiryForUpdatein interface- javax.cache.expiry.ExpiryPolicy
 
- 
getFactoryIdpublic int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
- getFactoryIdin interface- IdentifiedDataSerializable
- Returns:
- factory ID
 
- 
getClassIdpublic int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
- getClassIdin interface- IdentifiedDataSerializable
- Returns:
- type ID
 
- 
writeDataDescription copied from interface:DataSerializableWrites object fields to output stream- Specified by:
- writeDatain interface- DataSerializable
- Parameters:
- out- output
- Throws:
- IOException- if an I/O error occurs. In particular, an- IOExceptionmay be thrown if the output stream has been closed.
 
- 
readDataDescription copied from interface:DataSerializableReads fields from the input stream- Specified by:
- readDatain interface- DataSerializable
- Parameters:
- in- input
- Throws:
- IOException- if an I/O error occurs. In particular, an- IOExceptionmay be thrown if the input stream has been closed.
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
 
-