Package org.h2.util
Class CacheLRU
java.lang.Object
org.h2.util.CacheLRU
- All Implemented Interfaces:
Cache
A cache implementation based on the last recently used (LRU) algorithm.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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.static CachegetCache(CacheWriter writer, String cacheType, int cacheSize) Create a cache of the given type and size.intGet the maximum memory to be used.intGet the used size in KB.voidput(CacheObject rec) Add an element to the cache.booleanremove(int pos) Remove an object from the cache.voidsetMaxMemory(int maxKb) Set the maximum memory to be used by this cache.update(int pos, CacheObject rec) Update an element in the cache.
-
Method Details
-
getCache
Create a cache of the given type and size.- Parameters:
writer- the cache writercacheType- the cache typecacheSize- the size- Returns:
- the cache object
-
clear
public void clear()Description copied from interface:CacheClear the cache. -
put
Description copied from interface:CacheAdd 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. -
update
Description copied from interface:CacheUpdate an element in the cache. This will move the item to the front of the list. -
remove
public boolean remove(int pos) Description copied from interface:CacheRemove an object from the cache. -
find
Description copied from interface:CacheGet 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:CacheGet 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:CacheGet all objects in the cache that have been changed.- Specified by:
getAllChangedin interfaceCache- Returns:
- the list of objects
-
setMaxMemory
public void setMaxMemory(int maxKb) Description copied from interface:CacheSet the maximum memory to be used by this cache.- Specified by:
setMaxMemoryin interfaceCache- Parameters:
maxKb- the maximum size in KB
-
getMaxMemory
public int getMaxMemory()Description copied from interface:CacheGet the maximum memory to be used.- Specified by:
getMaxMemoryin interfaceCache- Returns:
- the maximum size in KB
-
getMemory
public int getMemory()Description copied from interface:CacheGet the used size in KB.
-