net.spy.db
Class SpyCacheDB

java.lang.Object
  extended bynet.spy.SpyObject
      extended bynet.spy.SpyDB
          extended bynet.spy.db.SpyCacheDB
Direct Known Subclasses:
DBSP

public class SpyCacheDB
extends SpyDB

Extensions to DB that allow for result set caching. Use wisely!


Field Summary
 
Fields inherited from class net.spy.SpyDB
INIT_FROM_CONFIG, INIT_FROM_CONN
 
Constructor Summary
SpyCacheDB(Connection conn)
          Get a SpyCacheDB object that will use the given Connection object for any needed queries.
SpyCacheDB(SpyConfig conf)
          Get a SpyCacheDB object as specified in the passed in config file.
 
Method Summary
 ResultSet executeQuery(String query, long lifetime)
          Execute if we don't have valid cache.
 PreparedStatement prepareStatement(String query, long lifetime)
          Prepare a statment for caching.
 
Methods inherited from class net.spy.SpyDB
close, dbquoteStr, executeQuery, executeUpdate, freeDBConn, getConfig, getConn, getInitType, getSource, init, isClosed, prepareCall, prepareStatement
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpyCacheDB

public SpyCacheDB(SpyConfig conf)
           throws SQLException
Get a SpyCacheDB object as specified in the passed in config file.

Throws:
SQLException - never, but it might someday.
See Also:
SpyConfig

SpyCacheDB

public SpyCacheDB(Connection conn)
Get a SpyCacheDB object that will use the given Connection object for any needed queries.

Method Detail

executeQuery

public ResultSet executeQuery(String query,
                              long lifetime)
                       throws SQLException
Execute if we don't have valid cache.

Parameters:
query - Query to execute
lifetime - How long (in seconds) the results can live
Throws:
SQLException - when bad stuff happens

prepareStatement

public PreparedStatement prepareStatement(String query,
                                          long lifetime)
                                   throws SQLException
Prepare a statment for caching.

Parameters:
query - Query to prepare
lifetime - How long (in seconds) the results can live
Throws:
SQLException - when bad stuff happens