commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@mail.lt>
Subject [dbutils]Cached Query
Date Sat, 01 Mar 2003 16:40:26 GMT
Hi,
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{
try{

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

  }finally{
    if(updateCount > 0){
      cache.clear();
   }
 }

}

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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message