org.riotfamily.cachius
Class CacheEntry

java.lang.Object
  extended by org.riotfamily.cachius.CacheEntry

public class CacheEntry
extends Object

Class that holds a reference to the actual cached data and a lock that can be used to synchronize the access. It also keeps track of the last access time so that least recently used items can be evicted if the cache capacity is exceeded.

Author:
Felix Gnass [fgnass at neteye dot de]

Constructor Summary
CacheEntry(String key, File cacheDir)
           
 
Method Summary
protected  void delete()
           
 boolean equals(Object obj)
           
 CacheItem getItem()
           
 String getKey()
          Returns the key.
 long getLastAccess()
          Returns the last access time.
protected  java.util.concurrent.locks.ReentrantReadWriteLock getLock()
          Returns the lock.
 int hashCode()
           
 CacheItem newItem()
           
 void replaceItem(CacheItem newItem)
           
 String toString()
           
protected  void touch()
          Sets the lastUsed timestamp to the current time.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheEntry

public CacheEntry(String key,
                  File cacheDir)
           throws IOException
Throws:
IOException
Method Detail

getKey

public String getKey()
Returns the key.


getItem

public CacheItem getItem()

replaceItem

public void replaceItem(CacheItem newItem)

newItem

public CacheItem newItem()
                  throws IOException
Throws:
IOException

getLock

protected java.util.concurrent.locks.ReentrantReadWriteLock getLock()
Returns the lock.


touch

protected void touch()
Sets the lastUsed timestamp to the current time.


getLastAccess

public long getLastAccess()
Returns the last access time.


delete

protected void delete()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object