V
- the type of the value stored by this AbstractCacheRecord
public abstract class AbstractCacheRecord<V,E> extends Object implements CacheRecord<V,E>, IdentifiedDataSerializable
CacheRecord
with key, value and
expiration time as internal state.
This implementation provides getter, setter and serialization methods.
Modifier and Type | Field and Description |
---|---|
protected int |
accessHit |
protected long |
accessTime |
protected long |
creationTime |
protected long |
expirationTime |
static Version |
EXPIRY_POLICY_VERSION
Represents when
ICache.setExpiryPolicy(Object, ExpiryPolicy) is added. |
TIME_NOT_AVAILABLE
Modifier | Constructor and Description |
---|---|
protected |
AbstractCacheRecord() |
|
AbstractCacheRecord(long creationTime,
long expirationTime) |
Modifier and Type | Method and Description |
---|---|
int |
getAccessHit()
Gets the access hit count of this
Evictable . |
long |
getCreationTime()
Gets the creation time of this
Evictable in milliseconds. |
long |
getExpirationTime()
Gets the expiration time in milliseconds.
|
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
long |
getLastAccessTime()
Gets the latest access time difference of this
Evictable in milliseconds. |
void |
incrementAccessHit()
Increases the access hit count of this
Evictable as 1 . |
boolean |
isExpiredAt(long now)
Checks whether the expiration time is passed with respect to the provided time.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
void |
resetAccessHit()
Resets the access hit count of this
Evictable to 0 . |
void |
setAccessHit(int accessHit)
Sets the access hit count of this
Evictable . |
void |
setAccessTime(long accessTime)
Sets the access time of this
Evictable in milliseconds. |
void |
setCreationTime(long creationTime)
Sets the creation time of this
Evictable in milliseconds. |
void |
setExpirationTime(long expirationTime)
Sets the expiration time in milliseconds.
|
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExpiryPolicy, setExpiryPolicy, setValue
getId
public static final Version EXPIRY_POLICY_VERSION
ICache.setExpiryPolicy(Object, ExpiryPolicy)
is added.
The constant is used in selective serialization of CacheRecord
s.protected long creationTime
protected volatile long expirationTime
protected volatile long accessTime
protected volatile int accessHit
protected AbstractCacheRecord()
public AbstractCacheRecord(long creationTime, long expirationTime)
public long getExpirationTime()
Expirable
getExpirationTime
in interface Expirable
System.currentTimeMillis()
public void setExpirationTime(long expirationTime)
Expirable
setExpirationTime
in interface Expirable
System.currentTimeMillis()
public long getCreationTime()
Evictable
Evictable
in milliseconds.getCreationTime
in interface Evictable<V>
Evictable
in millisecondspublic void setCreationTime(long creationTime)
CacheRecord
Evictable
in milliseconds.setCreationTime
in interface CacheRecord<V,E>
creationTime
- the creation time for this Evictable
in millisecondspublic long getLastAccessTime()
Evictable
Evictable
in milliseconds.getLastAccessTime
in interface Evictable<V>
Evictable
in millisecondspublic void setAccessTime(long accessTime)
CacheRecord
Evictable
in milliseconds.setAccessTime
in interface CacheRecord<V,E>
accessTime
- the latest access time of this Evictable
in millisecondspublic int getAccessHit()
Evictable
Evictable
.getAccessHit
in interface Evictable<V>
Evictable
public void setAccessHit(int accessHit)
CacheRecord
Evictable
.setAccessHit
in interface CacheRecord<V,E>
accessHit
- the access hit count for this Evictable
public void incrementAccessHit()
CacheRecord
Evictable
as 1
.incrementAccessHit
in interface CacheRecord<V,E>
public void resetAccessHit()
CacheRecord
Evictable
to 0
.resetAccessHit
in interface CacheRecord<V,E>
public boolean isExpiredAt(long now)
Expirable
Returns true if and only if now > getExpirationTime()
isExpiredAt
in interface Expirable
now
- time in milliseconds.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.public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.