org.ehcache.spi.cache
Class AbstractValueHolder<V>

java.lang.Object
  extended by org.ehcache.spi.cache.AbstractValueHolder<V>
All Implemented Interfaces:
java.io.Serializable, Store.ValueHolder<V>
Direct Known Subclasses:
OffHeapValueHolder, OnHeapValueHolder, XAValueHolder

public abstract class AbstractValueHolder<V>
extends java.lang.Object
implements Store.ValueHolder<V>, java.io.Serializable

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ehcache.spi.cache.Store.ValueHolder
NO_EXPIRE
 
Constructor Summary
protected AbstractValueHolder(long id, long creationTime)
           
protected AbstractValueHolder(long id, long creationTime, long expirationTime)
           
 
Method Summary
 void accessed(long now, Duration expiration)
           
 long creationTime(java.util.concurrent.TimeUnit unit)
          Accessor to the creation time of this ValueHolder
 boolean equals(java.lang.Object obj)
           
 long expirationTime(java.util.concurrent.TimeUnit unit)
          Accessor to the expiration time of this ValueHolder
 long getId()
          The combination of this identifier and the key that ValueHolder is mapped to should to be unique at a given time.
 int hashCode()
           
 float hitRate(long now, java.util.concurrent.TimeUnit unit)
          Accessor to the hit rate of the Value held in this ValueHolder?
 long hits()
           
 boolean isExpired(long expirationTime, java.util.concurrent.TimeUnit unit)
          Check if the ValueHolder is expired relative to the specified time
 long lastAccessTime(java.util.concurrent.TimeUnit unit)
          Accessor to the last access time of the Value held in this ValueHolder
protected abstract  java.util.concurrent.TimeUnit nativeTimeUnit()
           
 void setExpirationTime(long expirationTime, java.util.concurrent.TimeUnit unit)
           
protected  void setHits(long hits)
           
 void setLastAccessTime(long lastAccessTime, java.util.concurrent.TimeUnit unit)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ehcache.spi.cache.Store.ValueHolder
value
 

Constructor Detail

AbstractValueHolder

protected AbstractValueHolder(long id,
                              long creationTime)

AbstractValueHolder

protected AbstractValueHolder(long id,
                              long creationTime,
                              long expirationTime)
Method Detail

nativeTimeUnit

protected abstract java.util.concurrent.TimeUnit nativeTimeUnit()

creationTime

public long creationTime(java.util.concurrent.TimeUnit unit)
Description copied from interface: Store.ValueHolder
Accessor to the creation time of this ValueHolder

Specified by:
creationTime in interface Store.ValueHolder<V>
Parameters:
unit - the timeUnit to return the creation time in
Returns:
the creation time in the given unit

setExpirationTime

public void setExpirationTime(long expirationTime,
                              java.util.concurrent.TimeUnit unit)

accessed

public void accessed(long now,
                     Duration expiration)

expirationTime

public long expirationTime(java.util.concurrent.TimeUnit unit)
Description copied from interface: Store.ValueHolder
Accessor to the expiration time of this ValueHolder

Specified by:
expirationTime in interface Store.ValueHolder<V>
Parameters:
unit - the timeUnit to return the creation time in
Returns:
the expiration time in the given unit. A value of Store.ValueHolder.NO_EXPIRE means that the ValueHolder will never expire.

isExpired

public boolean isExpired(long expirationTime,
                         java.util.concurrent.TimeUnit unit)
Description copied from interface: Store.ValueHolder
Check if the ValueHolder is expired relative to the specified time

Specified by:
isExpired in interface Store.ValueHolder<V>
Parameters:
expirationTime - the expiration time relative to which the expiry check must be made
unit - the unit of the expiration time
Returns:
true if the ValueHolder expired relative to the given expiration time

lastAccessTime

public long lastAccessTime(java.util.concurrent.TimeUnit unit)
Description copied from interface: Store.ValueHolder
Accessor to the last access time of the Value held in this ValueHolder

Specified by:
lastAccessTime in interface Store.ValueHolder<V>
Parameters:
unit - the timeUnit to return the last access time in
Returns:
the last access time in the given unit

setLastAccessTime

public void setLastAccessTime(long lastAccessTime,
                              java.util.concurrent.TimeUnit unit)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hitRate

public float hitRate(long now,
                     java.util.concurrent.TimeUnit unit)
Description copied from interface: Store.ValueHolder
Accessor to the hit rate of the Value held in this ValueHolder?

Specified by:
hitRate in interface Store.ValueHolder<V>
Parameters:
now - the time in TimeUnit.MILLISECONDS upto which the rate needs to be calculated
unit - the TimeUnit in which the rate is to returned
Returns:
the hit rate in the given unit

hits

public long hits()
Specified by:
hits in interface Store.ValueHolder<V>
Returns:
hit counter of the Value held in this ValueHolder

setHits

protected void setHits(long hits)

getId

public long getId()
Description copied from interface: Store.ValueHolder
The combination of this identifier and the key that ValueHolder is mapped to should to be unique at a given time.

Specified by:
getId in interface Store.ValueHolder<V>
Returns:
a unique identifier

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object