|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.syncsoft.plainsql.StmtCache
public class StmtCache
This class creates an object which maintains a cache of recently executed statements. When a statement is executed by other methods in this package, the statement is stored here and retreived when subsequently executed. Statements age out of the cache on an LRU basis, although the insertion point need not be at the top of the LRU list - probably works a bit better if you insert statemnets in the middle of the list (so that a storm of one-off statements do not totally empty the cache)
| Constructor Summary | |
|---|---|
StmtCache(int cachesize,
int insertionPoint)
Initialize the Statment cache. |
|
| Method Summary | |
|---|---|
void |
add(PlainSql sqlStmt)
Add the specified SQL statement to the cache |
void |
display()
List out the contents of the cache and the cache hit rates |
PlainSql |
get(java.lang.String sql)
Get the cached statement corresponding to the nominated SQL You should call "isCached" first to make sure that the statement is actuall in there. |
int |
getCachesize()
Returns the size of the cache: the maximum number of Sqls which can be cached. |
int |
getElements()
Returns the number of SQLs in the cache. |
int |
getHits()
Returns the number of times a statement was found in the cache |
int |
getInsertionPoint()
Returns the insertion point - spot on the LRU chain where new entries will be added. |
int |
getMisses()
Returns the number of times a statement was sought but not found |
java.util.HashMap<java.lang.String,PlainSql> |
getStatementCache()
Return the statement cache object |
java.util.ArrayList<java.lang.String> |
getStatementLRU()
Returns the LRU list |
boolean |
isCached(java.lang.String sql)
Return TRUE if we have the SQL in the cache |
int |
position(java.lang.String sql)
Returns the position in the LRU chain of the specified SQL |
void |
setInsertionPoint(int insertionPoint)
Set the insertion point. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StmtCache(int cachesize,
int insertionPoint)
cachesize - Size of the cache (# of statements)insertionPoint - Where to put new statements (half way is probably good)| Method Detail |
|---|
public void add(PlainSql sqlStmt)
sqlStmt - :
A PlainSql objectpublic void display()
public PlainSql get(java.lang.String sql)
sql - text of the Sql statement
public boolean isCached(java.lang.String sql)
sql -
public int position(java.lang.String sql)
sql -
public int getInsertionPoint()
public void setInsertionPoint(int insertionPoint)
insertionPoint - public int getCachesize()
public int getElements()
public int getHits()
public int getMisses()
public java.util.HashMap<java.lang.String,PlainSql> getStatementCache()
public java.util.ArrayList<java.lang.String> getStatementLRU()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||