3 Replies Latest reply on Nov 17, 2005 12:29 AM by ben.wang

    How to load objects through CacheLoader for TreeCacheAop?

      Hi,

      We currently use TreeCache to do local caching of some database objects. We created our own CacheLoader which will load/save the objects from the database as needed. The code to load the object from the database is added in the get(Fqn) method of the CacheLoader which returns the Map of all the attributes of the object. All this works fine.

      Now, we are trying to move to the TreeCacheAop which should make our code cleaner as we can directly operate on the objects and not worry about updating the attributes in the cache. However, we are unable to figure out where in the code path the putObject(Object) should be executed to attach the object to the cache. Our initial reaction was to load the object from the database as part of the get(Fqn) method in the CacheLoader and attach it to the cache using putObject method. If this is correct, what should be returned in the Map? Any help is very much appreciated.

      On a side note, I was looking at the CacheLoaderAop interface, but that doesn't seem to be used anywhere in the code. Any docs/examples on usage of this?

      Thanks,
      Satish

        • 1. Re: How to load objects through CacheLoader for TreeCacheAop

          CacheLoaderAop interface is not used right now. As for TreeCacheAop and CacheLoader, I have written some unit tests under functional/org/jboss/cache/aop/loader. You can check it out. On first thought, I'd assume if you are using CacheLoader interface, it should work. But I can be wrong.

          -Ben

          • 2. Re: How to load objects through CacheLoader for TreeCacheAop

            Hi Ben,

            Thanks for the reply. I looked at the test case, but what I see there is some objects put in to the cache to do a particular test and then retrieve them. What I am looking for is a way to load these objects lazily as needed based on the CacheLoader interface methods exists(Fqn) and get(Fqn). None of the AOP examples provided with the distribution cover this. My difficulty is to figure out how to load the objects dynamically when needed and attach them to the Aop Cache. Any ideas?

            Thanks,
            Satish

            • 3. Re: How to load objects through CacheLoader for TreeCacheAop

              Ah, ic. Yes, lzay loading is on todo plate. There is a Jira issue (JBCACHE-13) with it as well. I haven't had time to think about it yet. But if you have any suggestion, do let me know. :-)

              -Ben