|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jetspeed.cache.file.FileCache
public class 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 | |
---|---|
private Map |
cache
|
protected List |
listeners
|
private static org.apache.commons.logging.Log |
log
|
protected int |
maxSize
|
private FileCache.FileCacheScanner |
scanner
|
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(org.apache.jetspeed.cache.file.FileCacheEventListener listener)
Add a File Cache Event Listener |
int |
compare(Object o1,
Object o2)
Comparator function for sorting by last accessed during eviction |
protected void |
evict()
Evicts entries based on last accessed time stamp |
void |
evictAll()
Evicts all entries |
org.apache.jetspeed.cache.file.FileCacheEntry |
get(String key)
Gets an entry from the cache given a key |
Object |
getDocument(String key)
Gets an entry from the cache given a key |
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(File file,
Object document)
Puts a file entry in the file cache |
void |
put(String key,
Object document,
File rootFile)
Puts a file entry in the file cache |
Object |
remove(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 List listeners
private FileCache.FileCacheScanner scanner
private Map cache
private static final org.apache.commons.logging.Log log
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 org.apache.jetspeed.cache.file.FileCacheEntry get(String key)
key
- the key to look up the entry by
public Object getDocument(String key)
key
- the key to look up the entry by
public void put(File file, Object document) throws IOException
file
- The file to be put in the cachedocument
- the cached document
IOException
public void put(String key, Object document, File rootFile) throws IOException
path
- the full path name of the filedocument
- the cached document
IOException
public Object remove(String key)
key
- the full path name of the file
public void addListener(org.apache.jetspeed.cache.file.FileCacheEventListener listener)
listener
- the event listenerpublic void startFileScanner()
public void stopFileScanner()
protected void evict()
public void evictAll()
public int compare(Object o1, Object o2)
compare
in interface Comparator
public Iterator getIterator()
public int getSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |