com.hazelcast.cache.impl.record
Class AbstractCacheRecord<V>

java.lang.Object
  extended by com.hazelcast.cache.impl.record.AbstractCacheRecord<V>
Type Parameters:
V - the type of the value stored by this AbstractCacheRecord
All Implemented Interfaces:
Evictable, CacheRecord<V>, Expirable, DataSerializable
Direct Known Subclasses:
CacheDataRecord, CacheObjectRecord

public abstract class AbstractCacheRecord<V>
extends Object
implements CacheRecord<V>, DataSerializable

Abstract implementation of CacheRecord with key, value and expiration time as internal state.

This implementation provides getter, setter and serialization methods.


Field Summary
protected  int accessHit
           
protected  long accessTime
           
protected  long creationTime
           
protected  long expirationTime
           
 
Constructor Summary
protected AbstractCacheRecord()
           
  AbstractCacheRecord(long creationTime, long expirationTime)
           
 
Method Summary
 int getAccessHit()
          Gets the access hit count of this Evictable.
 long getAccessTime()
          Gets the latest access time difference of this Evictable in milliseconds.
 long getCreationTime()
          Gets the creation time of this Evictable in milliseconds.
 long getExpirationTime()
          Gets the expiration time 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.hazelcast.cache.impl.record.CacheRecord
getValue, setValue
 

Field Detail

creationTime

protected long creationTime

expirationTime

protected volatile long expirationTime

accessTime

protected volatile long accessTime

accessHit

protected volatile int accessHit
Constructor Detail

AbstractCacheRecord

protected AbstractCacheRecord()

AbstractCacheRecord

public AbstractCacheRecord(long creationTime,
                           long expirationTime)
Method Detail

getExpirationTime

public long getExpirationTime()
Description copied from interface: Expirable
Gets the expiration time in milliseconds.

Specified by:
getExpirationTime in interface Expirable
Returns:
expiration time.
See Also:
System.currentTimeMillis()

setExpirationTime

public void setExpirationTime(long expirationTime)
Description copied from interface: Expirable
Sets the expiration time in milliseconds.

Specified by:
setExpirationTime in interface Expirable
See Also:
System.currentTimeMillis()

getCreationTime

public long getCreationTime()
Description copied from interface: Evictable
Gets the creation time of this Evictable in milliseconds.

Specified by:
getCreationTime in interface Evictable
Returns:
the creation time of this Evictable in milliseconds

setCreationTime

public void setCreationTime(long creationTime)
Description copied from interface: CacheRecord
Sets the creation time of this Evictable in milliseconds.

Specified by:
setCreationTime in interface CacheRecord<V>
Parameters:
creationTime - the creation time for this Evictable in milliseconds

getAccessTime

public long getAccessTime()
Description copied from interface: Evictable
Gets the latest access time difference of this Evictable in milliseconds.

Specified by:
getAccessTime in interface Evictable
Returns:
the latest access time of this Evictable in milliseconds

setAccessTime

public void setAccessTime(long accessTime)
Description copied from interface: CacheRecord
Sets the access time of this Evictable in milliseconds.

Specified by:
setAccessTime in interface CacheRecord<V>
Parameters:
accessTime - the latest access time of this Evictable in milliseconds

getAccessHit

public int getAccessHit()
Description copied from interface: Evictable
Gets the access hit count of this Evictable.

Specified by:
getAccessHit in interface Evictable
Returns:
the access hit count of this Evictable

setAccessHit

public void setAccessHit(int accessHit)
Description copied from interface: CacheRecord
Sets the access hit count of this Evictable.

Specified by:
setAccessHit in interface CacheRecord<V>
Parameters:
accessHit - the access hit count for this Evictable

incrementAccessHit

public void incrementAccessHit()
Description copied from interface: CacheRecord
Increases the access hit count of this Evictable as 1.

Specified by:
incrementAccessHit in interface CacheRecord<V>

resetAccessHit

public void resetAccessHit()
Description copied from interface: CacheRecord
Resets the access hit count of this Evictable to 0.

Specified by:
resetAccessHit in interface CacheRecord<V>

isExpiredAt

public boolean isExpiredAt(long now)
Description copied from interface: Expirable
Checks whether the expiration time is passed with respect to the provided time.

Returns true if and only if now > getExpirationTime()

.

Specified by:
isExpiredAt in interface Expirable
Parameters:
now - time in milliseconds.
Returns:
true if expired.

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.