Expresso 5-6

com.jcorporate.expresso.core.cache
Class CacheEntry

java.lang.Object
  extended bycom.jcorporate.expresso.core.cache.CacheEntry

public final class CacheEntry
extends Object

Wrapper for any Cacheable object to be stored in a cache. This wrapper provides some utility services to the cacheable object, like maintaining it's usage count (for the least-frequently-used algorithm used to free up cache space when needed) and the expiry time of the object (for caches that use timed expiry of objects - e.g. keep it cached for x seconds)


Field Summary
protected  long created
          When created *
 
Constructor Summary
CacheEntry(Cacheable newContents)
          Constructor 1 Sets the object to expire in the default time
CacheEntry(Cacheable newContents, long newExpires)
          Constructor 2
 
Method Summary
 void clearUsedCount()
           
 Cacheable getContents()
           
 long getCreated()
           
 long getExpires()
           
 String getKey()
           
 long getUsedCount()
          Used for figuring out how often this has been used
 void incrementUsedCount()
           
 boolean isExpired()
          Checks if the object has expired.
 void setExpiration(long expiration)
          Set the expiration time for the cache entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

created

protected long created
When created *

Constructor Detail

CacheEntry

public CacheEntry(Cacheable newContents)
Constructor 1 Sets the object to expire in the default time

Parameters:
newContents - the Cacheable object you want to cache

CacheEntry

public CacheEntry(Cacheable newContents,
                  long newExpires)
Constructor 2

Parameters:
newContents - the object to cache
newExpires - how long before the object expires. In millis, e.g. 1000 = 1 second
Method Detail

clearUsedCount

public void clearUsedCount()

getContents

public Cacheable getContents()
Returns:
the object

getCreated

public long getCreated()
Returns:
when the object was created

getExpires

public long getExpires()
Returns:
when the object expires

getKey

public String getKey()
Returns:
the object

getUsedCount

public long getUsedCount()
Used for figuring out how often this has been used

Returns:
The number of times this entry has been used

incrementUsedCount

public void incrementUsedCount()

setExpiration

public void setExpiration(long expiration)
Set the expiration time for the cache entry.

Parameters:
expiration - time in milliseconds to hold the object before it expires.

isExpired

public final boolean isExpired()
Checks if the object has expired. If it has then it is to be purged from the cache.

Returns:
true if the object has expired

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.