|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.wayback.LRUCache
public class LRUCache
An LRU cache, based on LinkedHashMap
.
This cache has a fixed maximum number of elements (cacheSize
).
If the cache is full and another entry is added, the LRU (least recently used)
entry is dropped.
This class is thread-safe. All methods of this class are synchronized.
Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
Multi-licensed: EPL / LGPL / GPL / AL / BSD.
Modified slightly to fit the use of a wayback file cache.
Constructor Summary | |
---|---|
LRUCache()
Constructor, where the arguments for the primary constructor is read from settings. |
|
LRUCache(java.io.File dir,
int cacheSize)
Creates a new LRU cache. |
Method Summary | |
---|---|
void |
clear()
Clears the cache. |
java.io.File |
get(java.lang.String key)
Retrieves an entry from the cache. The retrieved entry becomes the MRU (most recently used) entry. |
java.io.File |
getCacheDir()
|
static LRUCache |
getInstance()
|
void |
put(java.lang.String key,
java.io.File value)
Adds an entry to this cache. |
int |
usedEntries()
Returns the number of used entries in the cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LRUCache(java.io.File dir, int cacheSize) throws IOFailure
dir
- The directory where the file is stored.cacheSize
- the maximum number of entries that will be kept
in this cache.
IOFailure
public LRUCache()
Method Detail |
---|
public static LRUCache getInstance()
public java.io.File get(java.lang.String key)
key
- the key whose associated value is to be returned.
public void put(java.lang.String key, java.io.File value)
key
- the key with which the specified value is to be associated.value
- a value to be associated with the specified key.public void clear()
public int usedEntries()
public java.io.File getCacheDir()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |