| 
				
  | 
|||||||||||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||||||||||
java.lang.Objectde.lmu.ifi.dbs.elki.persistent.LRUCache<P>
P - Page typepublic class LRUCache<P extends Page<P>>
An LRU cache, based on LinkedHashMap.
 This cache has a fixed maximum number of objects (cacheSize). If
 the cache is full and another object is added, the LRU (least recently used)
 object is dropped.
| Field Summary | |
|---|---|
protected  int | 
cacheSize
The maximum number of objects in this cache.  | 
protected  CachedFile<P> | 
file
The underlying file of this cache.  | 
private  LinkedHashMap<Integer,P> | 
map
The map holding the objects of this cache.  | 
private  long | 
pageAccess
The number of read accesses  | 
| Constructor Summary | |
|---|---|
LRUCache()
Creates a new empty LRU cache.  | 
|
| Method Summary | |
|---|---|
 void | 
clear()
Clears this cache.  | 
 void | 
flush()
Flushes this caches by writing any entry to the underlying file.  | 
 P | 
get(int pageID)
Retrieves a page from the cache.  | 
 long | 
getPageAccess()
Returns the number of page accesses.  | 
 void | 
initialize(int cacheSize,
           CachedFile<P> file)
Initializes this cache with the specified parameters.  | 
 void | 
put(P page)
Adds a page to this cache.  | 
 P | 
remove(int pageID)
Removes a page from this cache.  | 
 void | 
resetPageAccess()
Resets the pages access of this cache.  | 
 void | 
setCacheSize(int cacheSize)
Sets the maximum size of this cache.  | 
 String | 
toString()
Returns a string representation of this cache.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected int cacheSize
private LinkedHashMap<Integer,P extends Page<P>> map
protected CachedFile<P extends Page<P>> file
private long pageAccess
| Constructor Detail | 
|---|
public LRUCache()
| Method Detail | 
|---|
public void initialize(int cacheSize,
                       CachedFile<P> file)
initialize in interface Cache<P extends Page<P>>cacheSize - the maximum number of pages in this cachefile - the underlying file of this cache, if a page is dropped it is
        written to the filepublic P get(int pageID)
get in interface Cache<P extends Page<P>>pageID - the id of the page to be returned
public void put(P page)
put in interface Cache<P extends Page<P>>page - the page to be addedpublic P remove(int pageID)
remove in interface Cache<P extends Page<P>>pageID - the number of the node to be removed.
public void flush()
flush in interface Cache<P extends Page<P>>public long getPageAccess()
getPageAccess in interface Cache<P extends Page<P>>public String toString()
toString in class Objectpublic void clear()
clear in interface Cache<P extends Page<P>>public void setCacheSize(int cacheSize)
setCacheSize in interface Cache<P extends Page<P>>cacheSize - the cache size to be setpublic void resetPageAccess()
resetPageAccess in interface Cache<P extends Page<P>>
  | 
                
  | 
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||