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 Summary
ConstructorsConstructorDescriptionDefault 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 Summary
Modifier 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
-
HazelcastExpiryPolicy
public HazelcastExpiryPolicy()Default constructor to serialize/deserialize -
HazelcastExpiryPolicy
public 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 creationaccessMillis- expiry time in milliseconds after last accessupdateMillis- expiry time in milliseconds after last update
-
HazelcastExpiryPolicy
public 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 creationaccessDurationAmount- expiry time after last accessupdateDurationAmount- expiry time after last updatetimeUnit- time unit of the previous value parameters
-
HazelcastExpiryPolicy
public 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
-
HazelcastExpiryPolicy
public 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 creationaccess- expiry duration after last accessupdate- expiry duration after last update
-
-
Method Details
-
getExpiryForCreation
public javax.cache.expiry.Duration getExpiryForCreation()- Specified by:
getExpiryForCreationin interfacejavax.cache.expiry.ExpiryPolicy
-
getExpiryForAccess
public javax.cache.expiry.Duration getExpiryForAccess()- Specified by:
getExpiryForAccessin interfacejavax.cache.expiry.ExpiryPolicy
-
getExpiryForUpdate
public javax.cache.expiry.Duration getExpiryForUpdate()- Specified by:
getExpiryForUpdatein interfacejavax.cache.expiry.ExpiryPolicy
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryIdin interfaceIdentifiedDataSerializable- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassIdin interfaceIdentifiedDataSerializable- Returns:
- type ID
-
writeData
Description copied from interface:DataSerializableWrites object fields to output stream- Specified by:
writeDatain interfaceDataSerializable- Parameters:
out- output- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializableReads fields from the input stream- Specified by:
readDatain interfaceDataSerializable- Parameters:
in- input- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the input stream has been closed.
-
equals
-
hashCode
public int hashCode() -
toString
-