net.sourceforge.jtds.jdbc.cache
Class FastStatementCache

java.lang.Object
  |
  +--net.sourceforge.jtds.jdbc.cache.FastStatementCache
All Implemented Interfaces:
StatementCache

public class FastStatementCache
extends java.lang.Object
implements StatementCache

Implements a fast, low-overhead statement cache using a HashMap. This cache will never release objects and therefore does not incur the overhead associated with latching. This cache is ideal for environments where there is known to be a limited number of unique handles created during the life of the connection.

Version:
$Id: FastStatementCache.java,v 1.2 2004/10/26 12:53:36 alin_sinpalean Exp $
Author:
Brian Heineman

Field Summary
private  java.util.HashMap cache
           
 
Constructor Summary
FastStatementCache()
           
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Returns a statement handle associated with the specified key or null if the key specified does not have an associated statement handle.
 java.util.Collection getObsoleteHandles(java.util.Collection handles)
          The FastStatementCache implementation does not release cached statements, so this method will always return null.
 void put(java.lang.String key, java.lang.Object handle)
          Places the specified statement handle in the cache for the given key.
 void remove(java.lang.String key)
          Removes a statement key and handle from the cache for the specified key.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cache

private java.util.HashMap cache
Constructor Detail

FastStatementCache

public FastStatementCache()
Method Detail

get

public java.lang.Object get(java.lang.String key)
Returns a statement handle associated with the specified key or null if the key specified does not have an associated statement handle.
Specified by:
get in interface StatementCache
Parameters:
key - the statement key whose associated handle is to be returned
Returns:
statement handle

put

public void put(java.lang.String key,
                java.lang.Object handle)
Places the specified statement handle in the cache for the given key. If a key already exists in the cache, the handle will be overwritten.
Specified by:
put in interface StatementCache
Parameters:
key - the statement key to associated with the handle
handle - the statement handle

remove

public void remove(java.lang.String key)
Removes a statement key and handle from the cache for the specified key.
Specified by:
remove in interface StatementCache
Parameters:
key - the statement key whose associated handle is to be removed from the cache

getObsoleteHandles

public java.util.Collection getObsoleteHandles(java.util.Collection handles)
The FastStatementCache implementation does not release cached statements, so this method will always return null.
Specified by:
getObsoleteHandles in interface StatementCache
Parameters:
handles - the statement handles that are no longer being used
Returns:
always null


Generated on April 15 2005