3 Replies Latest reply on Nov 23, 2007 6:12 AM by aditsu

    Passivation and CacheLoader

    bedek

      Hi,

      I'm using jboss cache with jdbc persistence and understand fully passivation true/false setting but is it possible to achieve behavior like this setting options in xml configuration:

      a) When object is retrieved from RAM and he is NOT in there it WILL_NOT be retrieved from DB (but in jboss cache startup process all values from memory will be retrieved from DB)

      b) When object is putted to RAM is WILL be persisted in DB

        • 1. Re: Passivation and CacheLoader
          aditsu

          You can do that by using no cache loader at all. To preload values, just manually get them from the DB and put them in the cache.
          To persist changes, use a cache listener.

          At least that's what I did :)

          Adrian

          • 2. Re: Passivation and CacheLoader
            bedek

            Hi, thanx for anser, this idea look very interesting for me but still I have questions:

            1) What method/class are you using to preload data from DB to cache ?

            2) How to you persist data in DB - are you using some ready made method/class form org.jboss.cache ?


            "aditsu" wrote:
            You can do that by using no cache loader at all. To preload values, just manually get them from the DB and put them in the cache.
            To persist changes, use a cache listener.

            At least that's what I did :)

            Adrian


            • 3. Re: Passivation and CacheLoader
              aditsu

              Just custom code. If you want to use JDBCCacheLoader's table structure, then you can extract the code from JDBCCacheLoader for working with the db, and call it directly. Otherwise, just write your own. I use iBATIS.