Andrey Markhel
unread,May 2, 2012, 12:40:58 PM5/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ActiveJDBC Group
Hi, Igor. As I said earlier I'd implemented sql query(connection)
cache facility. It is appropriate for web-based applications, where
through one request some queries can be repeated and repeated(select *
from people where id = 1) There are no need to ping DB again and
again :), if data wasn't change.
So, I introduce methods in DB.java and Base.java
you can enable sql connection cache by :
1) new DB("default").enableSqlCache().open(driver(), url(), user(),
password());
2) Base.openCached(driver(), url(), user(), password());
After that, all similar requests will be cached. Cache will be purged
automatically if any INSERT\UPDATE\DELETE occurs. Also cache will be
cleared and removed in subsequent DB.close("default") when connection
closed.
Also, implemented cache is smart enough to find semantics equivalence
between "SELECT * from people Where id= ?"(param Long(1)) and
"select * from people where id = ?"(Integer(1)). Both queries is
identical for cache.
Also, for experiment I implement next feature - if results for query
("select * from people") exists, then query (select * from people
limit 2 offset 5) - will not trip to database, but will use data from
cache.
I'd wrote many test cases and comments, please, review branch
sqlQueryCache.