CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation

com.tangosol.net.cache
Class OldCache.Entry

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.SafeHashMap.Entry
          extended by com.tangosol.net.cache.OldCache.Entry
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map.Entry
Direct Known Subclasses:
LocalCache.Entry
Enclosing class:
OldCache

public class OldCache.Entry
extends SafeHashMap.Entry

A holder for a cached value.

Author:
cp 2001.04.19

Field Summary
 
Fields inherited from class com.tangosol.util.SafeHashMap.Entry
m_eNext, m_nHash, m_oKey, m_oValue
 
Constructor Summary
OldCache.Entry()
          Construct the cacheable entry that holds the cached value.
 
Method Summary
protected  int calculateUnits(java.lang.Object oValue)
          Calculate a cache cost for the specified object.
protected  void copyFrom(SafeHashMap.Entry entry)
          Copy this Entry's information from another Entry.
protected  void discard()
          Called to inform the Entry that it is no longer used.
 long getCreatedMillis()
          Determine when the cache entry was created.
 long getExpiryMillis()
          Determine when the cache entry will expire, if ever.
 long getLastTouchMillis()
          Determine when the cache entry was last touched.
 int getPriority()
          Calculate a cache priority.
 int getTouchCount()
          Determine the number of times that the cache entry has been touched.
 int getUnits()
          Determine the number of cache units used by this Entry.
protected  boolean isDiscarded()
          Determine if this entry has already been discarded from the cache.
 boolean isExpired()
          Determine if the cache entry has expired.
protected  void onAdd()
          This method is invoked when the containing Map has actually added this Entry to itself.
protected  void scheduleExpiry()
          Reschedule the cache entry expiration.
 void setExpiryMillis(long lMillis)
          Specify when the cache entry will expire, or disable expiry.
 void setUnits(int cUnits)
          Specify the number of cache units used by this Entry.
 java.lang.Object setValue(java.lang.Object oValue)
          Update the cached value.
 java.lang.String toString()
          Render the cache entry as a String.
 void touch()
          Called each time the entry is accessed or modified.
 
Methods inherited from class com.tangosol.util.SafeHashMap.Entry
clone, equals, getKey, getValue, hashCode
 

Constructor Detail

OldCache.Entry

public OldCache.Entry()
Construct the cacheable entry that holds the cached value.

Method Detail

onAdd

protected void onAdd()
This method is invoked when the containing Map has actually added this Entry to itself.

Overrides:
onAdd in class SafeHashMap.Entry

setValue

public java.lang.Object setValue(java.lang.Object oValue)
Update the cached value.

Specified by:
setValue in interface java.util.Map.Entry
Overrides:
setValue in class SafeHashMap.Entry
Parameters:
oValue - the new value to cache
Returns:
the old cache value

copyFrom

protected void copyFrom(SafeHashMap.Entry entry)
Copy this Entry's information from another Entry. Sub-classes must implement this method if they add any additional fields.

Overrides:
copyFrom in class SafeHashMap.Entry
Parameters:
entry - the entry to copy from

getPriority

public int getPriority()
Calculate a cache priority.

Returns:
a value between 0 and 10, 0 being the highest priority

getCreatedMillis

public long getCreatedMillis()
Determine when the cache entry was created.

Returns:
the date/time value, in millis, when the entry was created

touch

public void touch()
Called each time the entry is accessed or modified.


getLastTouchMillis

public long getLastTouchMillis()
Determine when the cache entry was last touched.

Returns:
the date/time value, in millis, when the entry was most recently touched

getTouchCount

public int getTouchCount()
Determine the number of times that the cache entry has been touched.

Returns:
the number of times that the cache entry has been touched

getExpiryMillis

public long getExpiryMillis()
Determine when the cache entry will expire, if ever.

Returns:
the date/time value, in millis, when the entry will (or did) expire; zero indicates no expiry

setExpiryMillis

public void setExpiryMillis(long lMillis)
Specify when the cache entry will expire, or disable expiry. Note that if the cache is configured for automatic expiry, each subsequent update to this cache entry will reschedule the expiry time.

Parameters:
lMillis - pass the date/time value, in millis, for when the entry will expire, or pass zero to disable automatic expiry

isExpired

public boolean isExpired()
Determine if the cache entry has expired.

Returns:
true if the cache entry was subject to automatic expiry and the current time is greater than the entry's expiry time

scheduleExpiry

protected void scheduleExpiry()
Reschedule the cache entry expiration.


discard

protected void discard()
Called to inform the Entry that it is no longer used.


isDiscarded

protected boolean isDiscarded()
Determine if this entry has already been discarded from the cache.

Returns:
true if this entry has been discarded

calculateUnits

protected int calculateUnits(java.lang.Object oValue)
Calculate a cache cost for the specified object.

The default implementation uses the unit calculator type of the containing cache.

Parameters:
oValue - the cache value to evaluate for unit cost
Returns:
an integer value 0 or greater, with a larger value signifying a higher cost

getUnits

public int getUnits()
Determine the number of cache units used by this Entry.

Returns:
an integer value 0 or greater, with a larger value signifying a higher cost; -1 implies that the Entry has been discarded

setUnits

public void setUnits(int cUnits)
Specify the number of cache units used by this Entry.

Parameters:
cUnits - an integer value 0 or greater, with a larger value signifying a higher cost

toString

public java.lang.String toString()
Render the cache entry as a String.

Overrides:
toString in class SafeHashMap.Entry
Returns:
the details about this Entry

CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation