|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jtds.jdbc.cache.ProcedureCache
LRU cache for procedures and statement handles.
Nested Class Summary | |
private static class |
ProcedureCache.CacheEntry
Encapsulates the cached Object and implements the linked list used to implement the LRU logic. |
Field Summary | |
private java.util.HashMap |
cache
The actual cache instance. |
(package private) int |
cacheSize
Maximum cache size or 0 to disable. |
(package private) java.util.ArrayList |
free
List of redundant cache entries. |
(package private) ProcedureCache.CacheEntry |
head
Head node of the linked list. |
private static int |
MAX_INITIAL_SIZE
The maximum initial HashMap size. |
(package private) ProcedureCache.CacheEntry |
tail
Tail node of the linked list. |
Constructor Summary | |
ProcedureCache(int cacheSize)
Constructs a new statement cache. |
Method Summary | |
java.lang.Object |
get(java.lang.String key)
Retrieves a ProcEntry object from the cache. |
java.util.Collection |
getObsoleteHandles(java.util.Collection handles)
Obtains a list of statement handles or procedures that can now be dropped. |
void |
put(java.lang.String key,
java.lang.Object handle)
Inserts a new entry, identified by a key, into the cache. |
void |
remove(java.lang.String key)
Removes a redundant entry from the cache. |
private void |
scavengeCache()
Removes unused entries trying to bring down the cache to the requested size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int MAX_INITIAL_SIZE
private java.util.HashMap cache
int cacheSize
ProcedureCache.CacheEntry head
ProcedureCache.CacheEntry tail
java.util.ArrayList free
Constructor Detail |
public ProcedureCache(int cacheSize)
cacheSize
- maximum cache size or 0 to disable cachingMethod Detail |
public java.lang.Object get(java.lang.String key)
get
in interface StatementCache
key
- the key value identifying the required entry
Object
or null if the entry
does not existpublic void put(java.lang.String key, java.lang.Object handle)
put
in interface StatementCache
key
- value used to identify the entryhandle
- proc entry to be inserted into the cachepublic void remove(java.lang.String key)
remove
in interface StatementCache
key
- value that identifies the cache entrypublic java.util.Collection getObsoleteHandles(java.util.Collection handles)
getObsoleteHandles
in interface StatementCache
handles
- a collection of single use statements that will be
returned for dropping if the cache is disabled
private void scavengeCache()
free
list.
Note: entries that are in use will not be removed so it is
possible for the cache to still be larger than cacheSize
after
the call finishes.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |