ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Pichlik <roman.pich...@systinet.com>
Subject Is Read Only Cache really per session?
Date Wed, 10 May 2006 16:37:13 GMT
i found this senetnces in documentation

"Serializable Read/Write Caches

As you may agree, caching per-session as described above may offer 
little benefit to global application performance. Another type of 
read/write cache that can offer a performance benefit to the entire 
application (i.e. not just per session) is a serializable read/write cache."

My multi-thread test show me (iBATIS log contains only one select) that 
Read Only Cahe isn`t per session, but works in the same way as 
Read/Write Cache (All sessions share same cache). Can you explain me that?

Test code:

<cacheModel id="blog-cache" type ="LRU" readOnly="true" serialize="false">
     <flushInterval hours="24"/>
     <flushOnExecute statement="Blog.save"/>
     <flushOnExecute statement="Blog.update"/>
     <flushOnExecute statement="Blog.delete"/>
     <property name="cache-size" value="1000" />

<select id="getAll" resultClass="blog" cacheModel="blog-cache">
         blog_id as blogId,
         blog_name as blogName,
         bloger_firstname as blogerFirstName,
         bloger_surname as blogerSurName,
         bloger_email as blogerEmail,

public class ReadOnlyCacheExampleII {

     public static void main(String args[]) throws Exception {
             for (int i = 0; i < 10; i++) {
                 new Client().start();
                 if(i == 0) {

      public static class Client extends Thread {
         public void run() {
             for (int i = 0; i < 100; i++) {
                 try{sleep(10*i);}catch(InterruptedException e){};
                 SqlMapSession session = null;
                     session = 
                     Blog blog = (Blog) 
session.queryForList("Blog.getAll" , null).get(0);
                     Blog blog2 = (Blog) 
session.queryForList("Blog.getAll" , null).get(0);

                     if(blog != blog2) {
                         throw new AssertionError();
                 } catch(SQLException e){
                 } finally{

thx, Dagi

This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

View raw message