ehcache

net.sf.ehcache.jcache
Class JCacheEntry

java.lang.Object
  extended by net.sf.ehcache.jcache.JCacheEntry
All Implemented Interfaces:
java.util.Map.Entry, net.sf.jsr107cache.CacheEntry

public class JCacheEntry
extends java.lang.Object
implements net.sf.jsr107cache.CacheEntry

An implementation of CacheEntry. A CacheEntry is metadata about an entry in the cache. It does not include the value.

Version:
$Id: JCacheEntry.java 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck

Constructor Summary
JCacheEntry(Element element)
          Constructor
 
Method Summary
 long getCost()
          This implementation does not have a notion of cost.
 long getCreationTime()
          Gets the creationTime attribute of the ElementAttributes object.
 long getExpirationTime()
          Returns the expiration time based on time to live.
 int getHits()
          Gets the hit count on this element.
 java.lang.Object getKey()
          Returns the key corresponding to this entry.
 long getLastAccessTime()
          Gets the last access time.
 long getLastUpdateTime()
          Updated means there was an existing Element that was replaced with a new one, for the same key.
 java.lang.Object getValue()
          Returns the value corresponding to this entry.
 long getVersion()
          Returns the version of the Element.
 boolean isValid()
          An Element is 'valid' if it is unexpired.
 java.lang.Object setValue(java.lang.Object value)
          Replaces the value corresponding to this entry with the specified value (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map.Entry
equals, hashCode
 

Constructor Detail

JCacheEntry

public JCacheEntry(Element element)
Constructor

Parameters:
element - an element from Ehcache
Method Detail

getKey

public java.lang.Object getKey()
                        throws java.lang.IllegalStateException
Returns the key corresponding to this entry.

Specified by:
getKey in interface java.util.Map.Entry
Returns:
the key corresponding to this entry.
Throws:
java.lang.IllegalStateException - implementations may, but are not required to, throw this exception if the entry has been removed from the backing map

getValue

public java.lang.Object getValue()
                          throws java.lang.IllegalStateException
Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Specified by:
getValue in interface java.util.Map.Entry
Returns:
the value corresponding to this entry.
Throws:
java.lang.IllegalStateException - implementations may, but are not required to, throw this exception if the entry has been removed from the backing map

setValue

public java.lang.Object setValue(java.lang.Object value)
                          throws java.lang.UnsupportedOperationException
Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Specified by:
setValue in interface java.util.Map.Entry
Parameters:
value - new value to be stored in this entry.
Returns:
old value corresponding to the entry.
Throws:
java.lang.UnsupportedOperationException - if the put operation is not supported by the backing map.

getCost

public long getCost()
This implementation does not have a notion of cost. Accordingly, 0 is always returned.

Specified by:
getCost in interface net.sf.jsr107cache.CacheEntry
Returns:
0

getCreationTime

public long getCreationTime()
Gets the creationTime attribute of the ElementAttributes object.

Specified by:
getCreationTime in interface net.sf.jsr107cache.CacheEntry
Returns:
The creationTime value

getExpirationTime

public long getExpirationTime()
Returns the expiration time based on time to live. If this element also has a time to idle setting, the expiry time will vary depending on whether the element is accessed.

Specified by:
getExpirationTime in interface net.sf.jsr107cache.CacheEntry
Returns:
the time to expiration

getHits

public int getHits()
Gets the hit count on this element. A new element has a hit count of 0.

Specified by:
getHits in interface net.sf.jsr107cache.CacheEntry
Returns:
the number of hits this Element has had. If the Element was updated, the hit count is reset to 0.

getLastAccessTime

public long getLastAccessTime()
Gets the last access time. Access means a get. So a newly created Element will have a last access time equal to its create time.

Specified by:
getLastAccessTime in interface net.sf.jsr107cache.CacheEntry

getLastUpdateTime

public long getLastUpdateTime()
Updated means there was an existing Element that was replaced with a new one, for the same key. If an update occurs, then the lastUpdateTime will be non-zero.

Specified by:
getLastUpdateTime in interface net.sf.jsr107cache.CacheEntry
Returns:
0 if never updated, otherwise the time the update occurred.

getVersion

public long getVersion()
Returns the version of the Element. This is based on timestamps.

Specified by:
getVersion in interface net.sf.jsr107cache.CacheEntry
Returns:
0 if the first version, otherwise the timestamp when the version was created.

isValid

public boolean isValid()
An Element is 'valid' if it is unexpired.

Specified by:
isValid in interface net.sf.jsr107cache.CacheEntry
Returns:
true if unexpired, otherwise false.

ehcache