com.hazelcast.cache
Class HazelcastExpiryPolicy

java.lang.Object
  extended by 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:

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:
Serialized Form

Constructor Summary
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.
 
Method Summary
 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 getId()
          Returns type identifier for this class.
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 creation
accessMillis - expiry time in milliseconds after last access
updateMillis - 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 a TimeUnit to 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

HazelcastExpiryPolicy

public HazelcastExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy)
Copy Constructor for an already existing ExpiryPolicy. 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 the Duration class.

Parameters:
create - expiry duration after creation
access - expiry duration after last access
update - expiry duration after last update
Method Detail

getExpiryForCreation

public javax.cache.expiry.Duration getExpiryForCreation()
Specified by:
getExpiryForCreation in interface javax.cache.expiry.ExpiryPolicy

getExpiryForAccess

public javax.cache.expiry.Duration getExpiryForAccess()
Specified by:
getExpiryForAccess in interface javax.cache.expiry.ExpiryPolicy

getExpiryForUpdate

public javax.cache.expiry.Duration getExpiryForUpdate()
Specified by:
getExpiryForUpdate in interface javax.cache.expiry.ExpiryPolicy

getFactoryId

public int getFactoryId()
Description copied from interface: IdentifiedDataSerializable
Returns DataSerializableFactory factory id for this class.

Specified by:
getFactoryId in interface IdentifiedDataSerializable
Returns:
factory id

getId

public int getId()
Description copied from interface: IdentifiedDataSerializable
Returns type identifier for this class. Id should be unique per DataSerializableFactory.

Specified by:
getId in interface IdentifiedDataSerializable
Returns:
type id

writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.