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.
 ObjectArray<CacheObject> getAllChanged()
          Get all objects in the cache that have been changed.
 int getMaxSize()
          Get the maximum size in words (4 bytes).
 int getSize()
          Get the used size in words (4 bytes).
 java.lang.String getTypeName()
          Get the name of the cache type in a human readable form.
 void put(CacheObject r)
          Add an element to the cache.
 void remove(int pos)
          Remove an object from the cache.
 void setMaxSize(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

ObjectArray<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)
         throws java.sql.SQLException
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
Throws:
java.sql.SQLException

update

CacheObject update(int pos,
                   CacheObject record)
                   throws java.sql.SQLException
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
Throws:
java.sql.SQLException

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

setMaxSize

void setMaxSize(int size)
                throws java.sql.SQLException
Set the maximum memory to be used by this cache.

Parameters:
size - in number of double words (4 bytes)
Throws:
java.sql.SQLException

getTypeName

java.lang.String getTypeName()
Get the name of the cache type in a human readable form.

Returns:
the cache type name

getMaxSize

int getMaxSize()
Get the maximum size in words (4 bytes).

Returns:
the maximum size in number of double words (4 bytes)

getSize

int getSize()
Get the used size in words (4 bytes).

Returns:
the current size in number of double words (4 bytes)