Caching of the database queries

Discussions

EJB design: Caching of the database queries

  1. Caching of the database queries (9 messages)

    Hello,

    I want to cache my read only queries(complex joins involved) in the weblogic server 5.1 which is clustered. We tried toplink but it failed to do caching for joins, cocobase is also ruled out. Is there any other commercial OR mapping tool which can get the work done, or should I design singleton classes with hashtables and session beans for caching? I will appreciate any comments.

    Thanks

    Vaneet

    Threaded Messages (9)

  2. Caching of the database queries[ Go to top ]

    For a similar problem, we use one stateless session bean to store results from previous selects.

    Michael
  3. Caching of the database queries[ Go to top ]

    Dont use singleton design patterns. They tend to be not singletons at all due to custom ClassLoader implementations used by application server vendors.

    What about a simple stateless bean which acts as the cache and stores the data as readonly static members. This meets properly with section 18.1.2 of the spec and would give you a logical if not physical singleton access to cached data.

    Dave Wolf
    Internet Applications Division
    Sybase
  4. Caching of the database queries[ Go to top ]

    Hi Dave,

    Thanks for your reply. I was going thro' the 18.1.2 (programming restriction) specs and I am not sure which particular restriction you were talking about.

    Thanks again.

    Vaneet
  5. Caching of the database queries[ Go to top ]

    The restriction on avoiding non read-only static members. This restriction exists due to custom class loader restrictions and the possibility some containers may use mulple VM's.

    Dave Wolf
    Internet Applications Division
    Sybase
  6. Caching of the database queries[ Go to top ]

    Dave,

      Does this mean if your app servers uses multiple jvm within a system or your running in a clustered environment you can't reliably cache data in your session bean?

    Tony
  7. Caching of the database queries[ Go to top ]

    Tony,

    Well is can be a concern if the cache is not read-only as you will find the static and singleton data is out of sync across VM's or ClassLoaders. In readonly data this wouldnt be an issue, but in dynamic data it would be. Thats why 18.1.2 forbids doing it.

    Dave Wolf
    Internet Applications Division
    Sybase
  8. Caching of the database queries[ Go to top ]

    Why not use the new CachedRowSet class (available at Suns site though the early access program) and attach it to the server context via JNDI? We have been using the CachedRowSet for a couple of weeks now and while we haven't used it in this capacity I don't see any reason why it wouldn't work.
  9. Caching of the database queries[ Go to top ]

    Hi Steve,

    Can you provide a sample code of what you had implemented using CachedRowSet. I will appreciate it. You can mail it at vaneet dot gupta at csfb dot com

    Thanks

    Vaneet
  10. Memcached is an option which shall be tried for read only result set based cache. It is also highly scalable. If you want to cache tables which shall be modified also, then result set based read only cache options may not solve your purpose. CSQL Cache, middle tier fully transactional bidirectional updateable caching mechanism might help in that case. It gives 20- 100 times performance improvement. Check out the below article for more infomation http://www.general.databasecorner.com/resource,4200,csql-main-memory-database-management-system-and-middle-tier-cache.aspx It is open source product and shall be downloaded from the below link http://www.sourceforge.net/projects/csql http://www.databasecache.com