commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <>
Subject [dbutils]Cached Query
Date Sat, 01 Mar 2003 16:40:26 GMT
This works for some use cases, no triggers and sole app uses db (the most of
trivial web applications)

 Object  executeCachedQuery( params )throws SQLException{
  Wrapper cached = cache.get(params);
   if(cached == null ){

     cached = new Wrapper( executeQuery(params) );
     cache.put(params, cached);

  return cached.result;


int executeUpdateNoFlush( params )throws SQLException{

//the same as executeUpadate is at this time


int executeUpdate( params )throws SQLException{

  int updateCount = 1;   // flush on exeption
  updateCount =   executeUpdateNoFlush(params);
  return updateCount;

    if(updateCount > 0){


It good to have option to dissable and flush cache programmicaly.
I have used it once without problems (implemented cacing wrapper for
driver), but I am not sure it is good idea (there are a lot of better ways
to implement cache).
Possible it is antipattern, but it helps to optimize legacy applications.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message