Package org.h2.util
Interface Cache
- All Known Implementing Classes:
CacheLRU
,CacheSecondLevel
,CacheTQ
public interface Cache
The cache keeps frequently used objects in the main memory.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the cache.find
(int pos) Get an element from the cache if it is available.get
(int pos) Get an element in the cache if it is available.Get all objects in the cache that have been changed.int
Get the maximum memory to be used.int
Get the used size in KB.void
put
(CacheObject r) Add an element to the cache.boolean
remove
(int pos) Remove an object from the cache.void
setMaxMemory
(int size) Set the maximum memory to be used by this cache.update
(int pos, CacheObject record) Update an element in the cache.
-
Method Details
-
getAllChanged
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
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
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
Update an element in the cache. This will move the item to the front of the list.- Parameters:
pos
- the unique key of the elementrecord
- the element- Returns:
- the element
-
remove
boolean remove(int pos) Remove an object from the cache.- Parameters:
pos
- the unique key of the element- Returns:
- true if the key was in the cache
-
find
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
-