com.continuent.tungsten.replicator.database
Class PreparedStatementCache

java.lang.Object
  extended by com.continuent.tungsten.replicator.database.PreparedStatementCache
All Implemented Interfaces:
CacheResourceManager<PreparedStatementHolder>

public class PreparedStatementCache
extends java.lang.Object
implements CacheResourceManager<PreparedStatementHolder>

Implements a cache for prepared statements, which are identified by a single key.


Constructor Summary
PreparedStatementCache(int capacity)
          Creates a new table metadata cache.
 
Method Summary
 void invalidate(java.lang.String key)
          Release one prepared statement.
 void invalidateAll()
          Release all metadata in the cache.
 void release(PreparedStatementHolder psh)
          Release resources for this metadata value.
 java.sql.PreparedStatement retrieve(java.lang.String key)
          Retrieves prepared statement or returns null if it is not in the cache.
 PreparedStatementHolder retrieveExtended(java.lang.String key)
          Retrieves prepared statement plus query text or returns null if not in the cache.
 int size()
          Returns the number of entries in the metadata cache.
 void store(java.lang.String key, java.sql.PreparedStatement ps, java.lang.String query)
          Store prepared statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreparedStatementCache

public PreparedStatementCache(int capacity)
Creates a new table metadata cache.

Method Detail

release

public void release(PreparedStatementHolder psh)
Description copied from interface: CacheResourceManager
Release resources for this metadata value.

Specified by:
release in interface CacheResourceManager<PreparedStatementHolder>

size

public int size()
Returns the number of entries in the metadata cache.


store

public void store(java.lang.String key,
                  java.sql.PreparedStatement ps,
                  java.lang.String query)
Store prepared statement.


retrieve

public java.sql.PreparedStatement retrieve(java.lang.String key)
Retrieves prepared statement or returns null if it is not in the cache.


retrieveExtended

public PreparedStatementHolder retrieveExtended(java.lang.String key)
Retrieves prepared statement plus query text or returns null if not in the cache.


invalidate

public void invalidate(java.lang.String key)
Release one prepared statement.


invalidateAll

public void invalidateAll()
Release all metadata in the cache.