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:
Sample usage:
ICache<Key, Value> unwrappedCache = cache.unwrap( ICache.class ); HazelcastExpiryPolicy customExpiry = new HazelcastExpiryPolicy(20, 30, 40, TimeUnit.SECONDS); unwrappedCache.put("key1", value, customExpiry );
Constructor and Description |
---|
HazelcastExpiryPolicy()
Default constructor to serialize/deserialize
|
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 the
Duration class. |
HazelcastExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy)
Copy Constructor for an already existing
ExpiryPolicy . |
HazelcastExpiryPolicy(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 a
TimeUnit to convert those values to internally used time unites. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
getClassId()
Returns type identifier for this class.
|
javax.cache.expiry.Duration |
getExpiryForAccess() |
javax.cache.expiry.Duration |
getExpiryForCreation() |
javax.cache.expiry.Duration |
getExpiryForUpdate() |
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
hashCode() |
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
String |
toString() |
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public HazelcastExpiryPolicy()
public HazelcastExpiryPolicy(long createMillis, long accessMillis, long updateMillis)
createMillis
- expiry time in milliseconds after creationaccessMillis
- expiry time in milliseconds after last accessupdateMillis
- expiry time in milliseconds after last updatepublic HazelcastExpiryPolicy(long createDurationAmount, long accessDurationAmount, long updateDurationAmount, TimeUnit timeUnit)
TimeUnit
to convert those values to internally used time unites.createDurationAmount
- expiry time after creationaccessDurationAmount
- expiry time after last accessupdateDurationAmount
- expiry time after last updatetimeUnit
- time unit of the previous value parameterspublic HazelcastExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy)
ExpiryPolicy
. Values are
copied to the internal state as is.expiryPolicy
- expiry policy to copypublic HazelcastExpiryPolicy(javax.cache.expiry.Duration create, javax.cache.expiry.Duration access, javax.cache.expiry.Duration update)
Duration
class.create
- expiry duration after creationaccess
- expiry duration after last accessupdate
- expiry duration after last updatepublic javax.cache.expiry.Duration getExpiryForCreation()
getExpiryForCreation
in interface javax.cache.expiry.ExpiryPolicy
public javax.cache.expiry.Duration getExpiryForAccess()
getExpiryForAccess
in interface javax.cache.expiry.ExpiryPolicy
public javax.cache.expiry.Duration getExpiryForUpdate()
getExpiryForUpdate
in interface javax.cache.expiry.ExpiryPolicy
public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getClassId()
IdentifiedDataSerializable
getClassId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2023 Hazelcast, Inc.. All rights reserved.