2 Replies Latest reply on Jul 14, 2005 3:32 PM by gregorypierce

    TreeCacheAOP and CacheLoader

      Hey folks,

      I've listened to the presentations (nice) and read through the docs but I can't really tell what the appropriate strategy is for using CacheLoaders with TreeCacheAOP. I can see the approach for using it with a regular TreeCache in the docs, but it doesn't seem to be clear how to extend this approach for TreeCacheAOP.

      Background
      ========
      Here is what I'm wantign to experiment with. What I want to do is put regular objects in the cache, but I want to have a database backstore that has hibernate in front of it. So when a user request something from the cache, I want my CacheLoader to be called if something isn't in the cache. In my cacheloader I want to just use Hibernate to retrieve from persistence storage the file as defined in some custom mapping and then populate that in the cache - as well as have that object get replication to the other members of the group.


      So after reading through all the docs this seems to be possible, but I can't find anything about CacheLoaders and how they interface with TreeCacheAOP. Everything in the comments in the doc talk about updating fields in a hashmap. If you folks have any examples of this anywhere that would be great or if there is some updated documentation that addresses this (I'm reading the TreeCacheAOP and TreeCache docs - but there is no publish date on them) I would greatly appreciate this.

      TreeCache combined with JGroups looks like its going to be the glue that solves a LOT of my problems so I want to make sure I understand it before 'betting the farm' on it :)

        • 1. Re: TreeCacheAOP and CacheLoader

          THe purpose of CacheLoader is to persist your state. As a result, the DB table is very simple since it is a blob. So I don't understand why you need to front it with Hibernate?

          -Ben

          • 2. Re: TreeCacheAOP and CacheLoader

            Well what I've been thinking is creating a cluster of JBossCache instances which each in turn are attached to a database distributed over a large number of LAN and WAN machines running almost as a grid with some webservice front end.

            In front of the cache I want to put some silly POJOs for a login service (for example - don't really want to do this). So now when my authentication manager says - "hey cache, give me this guy /company/foobar/user/blah", the cache will say "hmmm... I don't know this guy, lemme instantiate this object and insert it in the cache. When this happens I'm looking at the CacheLoader as a way to short circuit this entire process so when the cache miss happens, the CacheLoader is passed the information (which would pretty much be the key in this case) necessary to instantiate this object into memory and insert it into the cache.

            So I'm looking at a hibernate layer as a way to bring the POJOs into memory so they can be inserted in the cache and that's what I was looking at the CacheLoader as doing.

            Hopefully that made more sense then what I said before and that I'm not using the product in the wrong way.