wt.pom
Class StatementCache
java.lang.Object
java.util.AbstractMap
wt.util.Cache
wt.pom.StatementCache
- All Implemented Interfaces:
- Map
- public class StatementCache
- extends Cache
A fixed size cache of java.sql.Statement
objects
indexed by SQL string.
- See Also:
Cache
Nested classes inherited from class java.util.AbstractMap |
|
Constructor Summary |
StatementCache(int size,
int reuse_limit)
Construct a new StatementCache |
Methods inherited from class wt.util.Cache |
containsKey, containsValue, createEntry, entries, entrySet, find, getAndRemove, getAndReplace, getKeys, keySet, link, print, size, toString, touch |
versionID
private static final String versionID
- See Also:
- Constant Field Values
reuseLimit
private int reuseLimit
count
private int count
StatementCache
public StatementCache(int size,
int reuse_limit)
- Construct a new
StatementCache
- Parameters:
size
- number of entries in the cachereuse_limit
- limit to number of times a cached statement is used (0 = infinite)
get
public Object get(Object key)
- Get an entry from the cache.
If an entry is found, it is considered busy until later freed to prevent
it from being used recursively or closed by cache overflow.
- Specified by:
get
in interface Map
- Overrides:
get
in class Cache
- Parameters:
key
- the entry key
- Returns:
- the cached object or null if not found
put
public Object put(Object key,
Object value)
- Put an entry in the cache.
If an entry for the given key already exists, the previous value is discarded.
This entry is considered the most recently used.
- Specified by:
put
in interface Map
- Overrides:
put
in class Cache
- Parameters:
key
- the entry keyvalue
- the value to associate with the given key
- Returns:
- The previous value that mapped to the key, or null if there
was no previous value
remove
public Object remove(Object key)
- Remove an entry in the cache.
- Specified by:
remove
in interface Map
- Overrides:
remove
in class Cache
- Parameters:
key
- the entry key
free
public void free(Object key,
Object stmt)
- Free an entry in the cache for reuse.
- Parameters:
key
- the entry keystmt
- the statement
- Returns:
- the cached object or null if not found
clear
public void clear()
- Empty the cache.
Closes any statements in the cache, ignoring any exceptions.
- Specified by:
clear
in interface Map
- Overrides:
clear
in class Cache
- See Also:
Cache
overflow
protected void overflow(Object key,
Object value)
- Called when an entry is being aged out of the cache.
Closes the statement, ignoring any exceptions.
- Overrides:
overflow
in class Cache
- Parameters:
key
- the entry keyvalue
- the entry value