| java.lang.Object org.apache.jetspeed.cache.file.FileCache
FileCache | public class FileCache implements java.util.Comparator(Code) | | 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.
author: David S. Taylor David Sean Taylor version: $Id: FileCache.java 516448 2007-03-09 16:25:47Z ate $ |
Inner Class :protected class FileCacheScanner extends Thread | |
Constructor Summary | |
public | FileCache() Default constructor. | public | FileCache(long scanRate, int maxSize) | public | FileCache(int initialCapacity, int loadFactor, long scanRate, int maxSize) |
maxSize | protected int maxSize(Code) | | |
scanRate | protected long scanRate(Code) | | |
FileCache | public FileCache()(Code) | | Default constructor. Use default values for scanReate and maxSize
|
FileCache | public FileCache(long scanRate, int maxSize)(Code) | | Set scanRate and maxSize
Parameters: scanRate - how often in seconds to refresh and evict from the cache Parameters: maxSize - the maximum allowed size of the cache before eviction starts |
FileCache | public FileCache(int initialCapacity, int loadFactor, long scanRate, int maxSize)(Code) | | Set all parameters on the cache
Parameters: initialCapacity - the initial size of the cache as passed to HashMap Parameters: loadFactor - how full the hash table is allowed to get before increasing Parameters: scanRate - how often in seconds to refresh and evict from the cache Parameters: maxSize - the maximum allowed size of the cache before eviction starts |
addListener | public void addListener(FileCacheEventListener listener)(Code) | | Add a File Cache Event Listener
Parameters: listener - the event listener |
compare | public int compare(Object o1, Object o2)(Code) | | Comparator function for sorting by last accessed during eviction
|
evict | protected void evict()(Code) | | Evicts entries based on last accessed time stamp
|
evictAll | public void evictAll()(Code) | | Evicts all entries
|
get | public FileCacheEntry get(String key)(Code) | | Gets an entry from the cache given a key
Parameters: key - the key to look up the entry by the entry |
getDocument | public Object getDocument(String key)(Code) | | Gets an entry from the cache given a key
Parameters: key - the key to look up the entry by the entry |
getIterator | public Iterator getIterator()(Code) | | get an iterator over the cache values
iterator over the cache values |
getMaxSize | public int getMaxSize()(Code) | | Get the maximum size of the cache
the current maximum size of the cache |
getScanRate | public long getScanRate()(Code) | | Get the refresh scan rate
the current refresh scan rate in seconds |
getSize | public int getSize()(Code) | | get the size of the cache
the size of the cache |
put | public void put(File file, Object document) throws java.io.IOException(Code) | | Puts a file entry in the file cache
Parameters: file - The file to be put in the cache Parameters: document - the cached document |
put | public void put(String key, Object document, File rootFile) throws java.io.IOException(Code) | | Puts a file entry in the file cache
Parameters: path - the full path name of the file Parameters: document - the cached document |
remove | public Object remove(String key)(Code) | | Removes a file entry from the file cache
Parameters: key - the full path name of the file the entry removed |
setMaxSize | public void setMaxSize(int maxSize)(Code) | | Set the new maximum size of the cache
Parameters: maxSize - the maximum size of the cache |
setScanRate | public void setScanRate(long scanRate)(Code) | | Set the new refresh scan rate on managed files.
Parameters: scanRate - the new scan rate in seconds |
startFileScanner | public void startFileScanner()(Code) | | Start the file Scanner running at the current scan rate.
|
stopFileScanner | public void stopFileScanner()(Code) | | Stop the file Scanner
|
|
|