org.h2.util
Interface Cache

All Known Implementing Classes:
CacheLRU

public interface Cache

The cache keeps frequently used objects in the main memory.


Method Summary
 void clear()
          Clear the cache.
 CacheObject find(int pos)
          Get an element from the cache if it is available.
 CacheObject get(int pos)
          Get an element in the cache if it is available.
 java.util.ArrayList<CacheObject> getAllChanged()
          Get all objects in the cache that have been changed.
 int getMaxMemory()
          Get the maximum memory to be used.
 int getMemory()
          Get the used size in KB.
 void put(CacheObject r)
          Add an element to the cache.
 void remove(int pos)
          Remove an object from the cache.
 void setMaxMemory(int size)
          Set the maximum memory to be used by this cache.
 CacheObject update(int pos, CacheObject record)
          Update an element in the cache.
 

Method Detail

getAllChanged

java.util.ArrayList<CacheObject> getAllChanged()
Get all objects in the cache that have been changed.

Returns:
the list of objects

clear

void clear()
Clear the cache.


get

CacheObject get(int pos)
Get an element in the cache if it is available. This will move the item to the front of the list.

Parameters:
pos - the unique key of the element
Returns:
the element or null

put

void put(CacheObject r)
Add an element to the cache. Other items may fall out of the cache because of this. It is not allowed to add the same record twice.

Parameters:
r - the object

update

CacheObject update(int pos,
                   CacheObject record)
Update an element in the cache. This will move the item to the front of the list.

Parameters:
pos - the unique key of the element
record - the element
Returns:
the element

remove

void remove(int pos)
Remove an object from the cache.

Parameters:
pos - the unique key of the element

find

CacheObject find(int pos)
Get an element from the cache if it is available. This will not move the item to the front of the list.

Parameters:
pos - the unique key of the element
Returns:
the element or null

setMaxMemory

void setMaxMemory(int size)
Set the maximum memory to be used by this cache.

Parameters:
size - the maximum size in KB

getMaxMemory

int getMaxMemory()
Get the maximum memory to be used.

Returns:
the maximum size in KB

getMemory

int getMemory()
Get the used size in KB.

Returns:
the current size in KB