Top Description Methods
org.h2.util

public Interface Cache

Known Direct Implementers
org.h2.util.CacheLRU, org.h2.util.CacheSecondLevel, org.h2.util.CacheTQ
Imports
java.util.ArrayList

The cache keeps frequently used objects in the main memory.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clear the cache.

public CacheObject

Returns:

the element or null
find
(int
the unique key of the element
pos
)

Get an element from the cache if it is available.

public CacheObject

Returns:

the element or null
get
(int
the unique key of the element
pos
)

Get an element in the cache if it is available.

public ArrayList<CacheObject>

Returns:

the list of objects
getAllChanged
()

Get all objects in the cache that have been changed.

public int

Returns:

the maximum size in KB
getMaxMemory
()

Get the maximum memory to be used.

public int

Returns:

the current size in KB
getMemory
()

Get the used size in KB.

public void
put(CacheObject
the object
r
)

Add an element to the cache.

public boolean

Returns:

true if the key was in the cache
remove
(int
the unique key of the element
pos
)

Remove an object from the cache.

public void
setMaxMemory(int
the maximum size in KB
size
)

Set the maximum memory to be used by this cache.

public CacheObject

Returns:

the element
update
(int
the unique key of the element
pos
,
CacheObject
the element
record
)

Update an element in the cache.

Method Detail

clearback to summary
public void clear()

Clear the cache.

findback to summary
public 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:int

the unique key of the element

Returns:CacheObject

the element or null

getback to summary
public 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:int

the unique key of the element

Returns:CacheObject

the element or null

getAllChangedback to summary
public ArrayList<CacheObject> getAllChanged()

Get all objects in the cache that have been changed.

Returns:ArrayList<CacheObject>

the list of objects

getMaxMemoryback to summary
public int getMaxMemory()

Get the maximum memory to be used.

Returns:int

the maximum size in KB

getMemoryback to summary
public int getMemory()

Get the used size in KB.

Returns:int

the current size in KB

putback to summary
public 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:CacheObject

the object

removeback to summary
public boolean remove(int pos)

Remove an object from the cache.

Parameters
pos:int

the unique key of the element

Returns:boolean

true if the key was in the cache

setMaxMemoryback to summary
public void setMaxMemory(int size)

Set the maximum memory to be used by this cache.

Parameters
size:int

the maximum size in KB

updateback to summary
public 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:int

the unique key of the element

record:CacheObject

the element

Returns:CacheObject

the element