Top Description Fields Constructors Methods
org.h2.util

public Class CacheTQ

extends Object
implements Cache
Class Inheritance
All Implemented Interfaces
org.h2.util.Cache
Imports
java.util.ArrayList

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

Modifier and TypeField and Description
private final Cache
private int
private final Cache
private int
private final SmallLRUCache<Integer, Object>
pack-priv static final String

Constructor Summary

AccessConstructor and Description
pack-priv
CacheTQ(CacheWriter writer, int maxMemoryKb)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements org.h2.util.Cache.clear.

Clear the cache.

public CacheObject
find(int
the unique key of the element
pos
)

Implements org.h2.util.Cache.find.

Get an element from the cache if it is available.

public CacheObject
get(int
the unique key of the element
pos
)

Implements org.h2.util.Cache.get.

Get an element in the cache if it is available.

public ArrayList<CacheObject>
getAllChanged()

Implements org.h2.util.Cache.getAllChanged.

Get all objects in the cache that have been changed.

public int
getMaxMemory()

Implements org.h2.util.Cache.getMaxMemory.

Get the maximum memory to be used.

public int
getMemory()

Implements org.h2.util.Cache.getMemory.

Get the used size in KB.

public void
put(CacheObject
the object
r
)

Implements org.h2.util.Cache.put.

Add an element to the cache.

public boolean
remove(int
the unique key of the element
pos
)

Implements org.h2.util.Cache.remove.

Remove an object from the cache.

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

Implements org.h2.util.Cache.setMaxMemory.

Set the maximum memory to be used by this cache.

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

Implements org.h2.util.Cache.update.

Update an element in the cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fifoback to summary
private final Cache fifo
lastUsedback to summary
private int lastUsed
lruback to summary
private final Cache lru
maxMemoryback to summary
private int maxMemory
recentlyUsedback to summary
private final SmallLRUCache<Integer, Object> recentlyUsed
TYPE_NAMEback to summary
pack-priv static final String TYPE_NAME

Constructor Detail

CacheTQback to summary
pack-priv CacheTQ(CacheWriter writer, int maxMemoryKb)

Method Detail

clearback to summary
public void clear()

Implements org.h2.util.Cache.clear.

Doc from org.h2.util.Cache.clear.

Clear the cache.

Annotations
@Override
findback to summary
public CacheObject find(int pos)

Implements org.h2.util.Cache.find.

Doc from org.h2.util.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:int

the unique key of the element

Returns:CacheObject

the element or null

Annotations
@Override
getback to summary
public CacheObject get(int pos)

Implements org.h2.util.Cache.get.

Doc from org.h2.util.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:int

the unique key of the element

Returns:CacheObject

the element or null

Annotations
@Override
getAllChangedback to summary
public ArrayList<CacheObject> getAllChanged()

Implements org.h2.util.Cache.getAllChanged.

Doc from org.h2.util.Cache.getAllChanged.

Get all objects in the cache that have been changed.

Returns:ArrayList<CacheObject>

the list of objects

Annotations
@Override
getMaxMemoryback to summary
public int getMaxMemory()

Implements org.h2.util.Cache.getMaxMemory.

Doc from org.h2.util.Cache.getMaxMemory.

Get the maximum memory to be used.

Returns:int

the maximum size in KB

Annotations
@Override
getMemoryback to summary
public int getMemory()

Implements org.h2.util.Cache.getMemory.

Doc from org.h2.util.Cache.getMemory.

Get the used size in KB.

Returns:int

the current size in KB

Annotations
@Override
putback to summary
public void put(CacheObject r)

Implements org.h2.util.Cache.put.

Doc from org.h2.util.Cache.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:CacheObject

the object

Annotations
@Override
removeback to summary
public boolean remove(int pos)

Implements org.h2.util.Cache.remove.

Doc from org.h2.util.Cache.remove.

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

Annotations
@Override
setMaxMemoryback to summary
public void setMaxMemory(int maxMemoryKb)

Implements org.h2.util.Cache.setMaxMemory.

Doc from org.h2.util.Cache.setMaxMemory.

Set the maximum memory to be used by this cache.

Parameters
maxMemoryKb:int

the maximum size in KB

Annotations
@Override
updateback to summary
public CacheObject update(int pos, CacheObject record)

Implements org.h2.util.Cache.update.

Doc from org.h2.util.Cache.update.

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

Annotations
@Override