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
ConstructorDescriptionDefault 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 aTimeUnit
to 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 theDuration
class.HazelcastExpiryPolicy
(javax.cache.expiry.ExpiryPolicy expiryPolicy) Copy Constructor for an already existingExpiryPolicy
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Returns type identifier for this class.javax.cache.expiry.Duration
javax.cache.expiry.Duration
javax.cache.expiry.Duration
int
Returns DataSerializableFactory factory ID for this class.int
hashCode()
void
Reads fields from the input streamtoString()
void
Writes 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 aTimeUnit
to 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 theDuration
class.- 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:
getExpiryForCreation
in interfacejavax.cache.expiry.ExpiryPolicy
-
getExpiryForAccess
public javax.cache.expiry.Duration getExpiryForAccess()- Specified by:
getExpiryForAccess
in interfacejavax.cache.expiry.ExpiryPolicy
-
getExpiryForUpdate
public javax.cache.expiry.Duration getExpiryForUpdate()- Specified by:
getExpiryForUpdate
in interfacejavax.cache.expiry.ExpiryPolicy
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
writeData
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
equals
-
hashCode
public int hashCode() -
toString
-