Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.persistent
Interface Cache<P extends Page<P>>

Type Parameters:
P - Page type
All Known Implementing Classes:
LRUCache

public interface Cache<P extends Page<P>>

Defines the requirements for a cache that stores objects implementing the Page interface.

Author:
Elke Achtert

Method Summary
 void clear()
          Clears this cache.
 void flush()
          Flushes this cache by writing any entry to the underlying file.
 P get(int id)
          Retrieves a page from this 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 object)
          Adds an object to this cache.
 P remove(int id)
          Removes an object from this cache.
 void resetPageAccess()
          Resets the pages access of this cache.
 void setCacheSize(int cacheSize)
          Sets the maximum size of this cache.
 

Method Detail

initialize

void initialize(int cacheSize,
                CachedFile<P> file)
Initializes this cache with the specified parameters.

Parameters:
cacheSize - the maximum number of pages in this cache
file - the underlying file of this cache, if a page is dropped it is written to the file

get

P get(int id)
Retrieves a page from this cache.

Parameters:
id - the id of the page to be returned.
Returns:
the page associated to the id or null if no value with this key exists in the cache.

put

void put(P object)
Adds an object to this cache.

Parameters:
object - the object to be added

remove

P remove(int id)
Removes an object from this cache.

Parameters:
id - the id of the object to be removed
Returns:
the removed object

flush

void flush()
Flushes this cache by writing any entry to the underlying file.


clear

void clear()
Clears this cache.


setCacheSize

void setCacheSize(int cacheSize)
Sets the maximum size of this cache.

Parameters:
cacheSize - the cache size to be set

getPageAccess

long getPageAccess()
Returns the number of page accesses.

Returns:
the number of page accesses

resetPageAccess

void resetPageAccess()
Resets the pages access of this cache.


Release 0.2 (2009-07-06_1820)