Package org.h2.util
Class CacheTQ
java.lang.Object
org.h2.util.CacheTQ
- All Implemented Interfaces:
Cache
An alternative cache implementation. This implementation uses two caches: a
LRU cache and a FIFO cache. Entries are first kept in the FIFO cache, and if
referenced again then marked in a hash set. If referenced again, they are
moved to the LRU cache. Stream pages are never added to the LRU cache. It is
supposed to be more or less scan resistant, and it doesn't cache large rows
in the LRU cache.
-
Field Summary
Fields -
Constructor Summary
Constructors -
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 maxMemoryKb) Set the maximum memory to be used by this cache.update
(int pos, CacheObject record) Update an element in the cache.
-
Field Details
-
TYPE_NAME
- See Also:
-
lru
-
fifo
-
recentlyUsed
-
lastUsed
private int lastUsed -
maxMemory
private int maxMemory
-
-
Constructor Details
-
CacheTQ
CacheTQ(CacheWriter writer, int maxMemoryKb)
-
-
Method Details
-
clear
public void clear()Description copied from interface:Cache
Clear the cache. -
find
Description copied from interface:Cache
Get an element from the cache if it is available. This will not move the item to the front of the list. -
get
Description copied from interface:Cache
Get an element in the cache if it is available. This will move the item to the front of the list. -
getAllChanged
Description copied from interface:Cache
Get all objects in the cache that have been changed.- Specified by:
getAllChanged
in interfaceCache
- Returns:
- the list of objects
-
getMaxMemory
public int getMaxMemory()Description copied from interface:Cache
Get the maximum memory to be used.- Specified by:
getMaxMemory
in interfaceCache
- Returns:
- the maximum size in KB
-
getMemory
public int getMemory()Description copied from interface:Cache
Get the used size in KB. -
put
Description copied from interface:Cache
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. -
remove
public boolean remove(int pos) Description copied from interface:Cache
Remove an object from the cache. -
setMaxMemory
public void setMaxMemory(int maxMemoryKb) Description copied from interface:Cache
Set the maximum memory to be used by this cache.- Specified by:
setMaxMemory
in interfaceCache
- Parameters:
maxMemoryKb
- the maximum size in KB
-
update
Description copied from interface:Cache
Update an element in the cache. This will move the item to the front of the list.
-