|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jetspeed.cache.FileCache
FileCache keeps a cache of files up-to-date with a most simple eviction policy. The eviction policy will keep n items in the cache, and then start evicting the items ordered-by least used first. The cache runs a thread to check for both evictions and refreshes.
Nested Class Summary | |
protected class |
FileCache.FileCacheScanner
inner class that runs as a thread to scan the cache for updates or evictions |
Field Summary | |
protected java.util.List |
listeners
|
protected int |
maxSize
|
protected long |
scanRate
|
Constructor Summary | |
FileCache()
Default constructor. |
|
FileCache(int initialCapacity,
int loadFactor,
long scanRate,
int maxSize)
Set all parameters on the cache |
|
FileCache(long scanRate,
int maxSize)
Set scanRate and maxSize |
Method Summary | |
void |
addListener(FileCacheEventListener listener)
Add a File Cache Event Listener |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Comparator function for sorting by last accessed during eviction |
protected void |
evict()
Evicts entries based on last accessed time stamp |
FileCacheEntry |
get(java.lang.String key)
Gets an entry from the cache given a key |
java.lang.Object |
getDocument(java.lang.String key)
Gets an entry from the cache given a key |
java.util.Iterator |
getIterator()
get an iterator over the cache values |
int |
getMaxSize()
Get the maximum size of the cache |
long |
getScanRate()
Get the refresh scan rate |
int |
getSize()
get the size of the cache |
void |
put(java.io.File file,
java.lang.Object document)
Puts a file entry in the file cache |
void |
put(java.lang.String key,
java.lang.Object document)
Puts a file entry in the file cache |
java.lang.Object |
remove(java.lang.String key)
Removes a file entry from the file cache |
void |
setMaxSize(int maxSize)
Set the new maximum size of the cache |
void |
setScanRate(long scanRate)
Set the new refresh scan rate on managed files. |
void |
startFileScanner()
Start the file Scanner running at the current scan rate. |
void |
stopFileScanner()
Stop the file Scanner |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
Field Detail |
protected long scanRate
protected int maxSize
protected java.util.List listeners
Constructor Detail |
public FileCache()
public FileCache(long scanRate, int maxSize)
scanRate
- how often in seconds to refresh and evict from the cachemaxSize
- the maximum allowed size of the cache before eviction startspublic FileCache(int initialCapacity, int loadFactor, long scanRate, int maxSize)
initialCapacity
- the initial size of the cache as passed to HashMaploadFactor
- how full the hash table is allowed to get before increasingscanRate
- how often in seconds to refresh and evict from the cachemaxSize
- the maximum allowed size of the cache before eviction startsMethod Detail |
public void setScanRate(long scanRate)
scanRate
- the new scan rate in secondspublic long getScanRate()
public void setMaxSize(int maxSize)
maxSize
- the maximum size of the cachepublic int getMaxSize()
public FileCacheEntry get(java.lang.String key)
key
- the key to look up the entry by
public java.lang.Object getDocument(java.lang.String key)
key
- the key to look up the entry by
public void put(java.io.File file, java.lang.Object document) throws java.io.IOException
file
- The file to be put in the cachedocument
- the cached document
java.io.IOException
public void put(java.lang.String key, java.lang.Object document) throws java.io.IOException
document
- the cached document
java.io.IOException
public java.lang.Object remove(java.lang.String key)
key
- the full path name of the file
public void addListener(FileCacheEventListener listener)
listener
- the event listenerpublic void startFileScanner()
public void stopFileScanner()
protected void evict()
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
public java.util.Iterator getIterator()
public int getSize()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |