wt.pom
Class StatementCache

java.lang.Object
  extended byjava.util.AbstractMap
      extended bywt.util.Cache
          extended bywt.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 Class Summary
 
Nested classes inherited from class wt.util.Cache
Cache.CacheEntry
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
private  int count
           
private  int reuseLimit
           
private static String versionID
           
 
Fields inherited from class wt.util.Cache
agedOut, cacheSize, hashCodes, hits, keys, misses, modCount, tableSize, values
 
Constructor Summary
StatementCache(int size, int reuse_limit)
          Construct a new StatementCache
 
Method Summary
 void clear()
          Empty the cache.
 void free(Object key, Object stmt)
          Free an entry in the cache for reuse.
 Object get(Object key)
          Get an entry from the cache.
protected  void overflow(Object key, Object value)
          Called when an entry is being aged out of the cache.
 Object put(Object key, Object value)
          Put an entry in the cache.
 Object remove(Object key)
          Remove an entry in the cache.
 
Methods inherited from class wt.util.Cache
containsKey, containsValue, createEntry, entries, entrySet, find, getAndRemove, getAndReplace, getKeys, keySet, link, print, size, toString, touch
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, putAll, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

reuseLimit

private int reuseLimit

count

private int count
Constructor Detail

StatementCache

public StatementCache(int size,
                      int reuse_limit)
Construct a new StatementCache

Parameters:
size - number of entries in the cache
reuse_limit - limit to number of times a cached statement is used (0 = infinite)
Method Detail

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 key
value - 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 key
stmt - 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 key
value - the entry value