Package bitronix.tm.resource.jdbc
Class LruStatementCache
java.lang.Object
bitronix.tm.resource.jdbc.LruStatementCache
Last Recently Used PreparedStatement cache with eviction listeners
support implementation.
- Author:
- lorban, brettw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvictionListener(LruEvictionListener listener) protected voidclear()Evict all statements from the cache.The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement.A statement is put into the cache.voidremoveEvictionListener(LruEvictionListener listener)
-
Constructor Details
-
LruStatementCache
public LruStatementCache(int maxSize)
-
-
Method Details
-
get
The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement. However, it contains all other pertinent information such as SQL statement, autogeneratedkeys flag, cursor holdability, etc. See the equals() method in the JdbcPreparedStatementHandle class. It is a complete key for a cached statement. If there is a matching cached PreparedStatement, it will be set as the delegate in the provided JdbcPreparedStatementHandle.- Parameters:
key- the cache key- Returns:
- the cached JdbcPreparedStatementHandle statement, or null
-
put
A statement is put into the cache. This is called when a statement is first prepared and also when a statement is closed (by the client). A "closed" statement has it's usage counter decremented in the cache.- Parameters:
key- a prepared statement handle- Returns:
- a prepared statement
-
clear
protected void clear()Evict all statements from the cache. This likely happens on connection close. -
addEvictionListener
-
removeEvictionListener
-