Top Description Fields Constructors Methods
org.h2.util

pack-priv Class CacheSecondLevel

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

Cache which wraps another cache (proxy pattern) and adds caching using map. This is useful for WeakReference, SoftReference or hard reference cache.

Field Summary

Modifier and TypeField and Description
private final Cache
private final Map<Integer, CacheObject>

Constructor Summary

AccessConstructor and Description
pack-priv

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
size
)

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

baseCacheback to summary
private final Cache baseCache
mapback to summary
private final Map<Integer, CacheObject> map

Constructor Detail

CacheSecondLevelback to summary
pack-priv CacheSecondLevel(Cache cache, Map<Integer, CacheObject> map)

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 size)

Implements org.h2.util.Cache.setMaxMemory.

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

Set the maximum memory to be used by this cache.

Parameters
size: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