3 Replies Latest reply on May 16, 2007 1:25 PM by manik

    Can TreeCache do what I need?

    aditsu

      Hi, I'm looking for a caching solution that can do these things:
      - it should work in a cluster, with a single database used for persistent storage
      - initially, the caches will preload a specific set of data (different for each cache)
      - whenever an object is requested from a cache, if it is not already available, it should be retrieved from one of the other caches in the cluster; if it still can't be found, then it should be retrieved from the database
      - whenever an object is modified, the current cache should keep the new value, and it should invalidate it in all the other caches
      - whenever an object is loaded from the database or newly inserted in a cache, it should not be immediately replicated to the other caches, but only on demand
      - each cache should drop (evict?) objects as needed (because of memory constraints), and that should not directly affect other caches in the cluster
      - each cache should flush its modifications to the database at (configurable) regular intervals, in batches
      - if possible, each modification or insertion into a cache should be immediately serialized to a local file before finishing the transaction; these files should be deleted whenever the changes are flushed to the database
      - if possible, each cache should be able to listen to updates or inserts into other caches, based on certain conditions

      Can TreeCache (probably used with Hibernate) do these things? If it can, then could you briefly explain how to configure and use it to achieve these features?
      If you have questions about any point, I can give more details and reasons, and you can provide alternative solutions.

      Thanks
      Adrian

        • 1. Re: Can TreeCache do what I need?
          manik

          Hi - yes, JBoss Cache can do all of the above. Please have a look at the user guide in the JBoss Cache docs page for details of each feature.

          • 2. Re: Can TreeCache do what I need?
            aditsu

            Hi, thank you for your reply and for developing this great project.
            I see that the "TreeCache" name is being deprecated in favor of "JBoss Cache".

            I'm happy to hear that all those features are supported, however I was hoping for a bit more guidance. I had already read the user guide, but it's not really clear how to set up everything to achieve the desired results. I don't expect a complete configuration, but maybe some hints such as "configure replication this way", "use a foo cache loader with the bar option", "enable passivation", etc.

            I can probably figure out some of the options, but I'd like to specifically ask how to serialize changes to disk until they are flushed to the persistent store (and delete the files after flushing).

            Thanks
            Adrian

            • 3. Re: Can TreeCache do what I need?
              manik

              It is best that you go thru the docs and set up your system accordingly, and then post specific tuning questions here rather than an all-encompassing discussion.



              I can probably figure out some of the options, but I'd like to specifically ask how to serialize changes to disk until they are flushed to the persistent store (and delete the files after flushing).



              I presume you mean the CacheLoader here. CacheLoaders can use a variety of backing stores to offload cache data to disk, although this isn't a "temp" space. Flushing to a CacheLoader can happen synchronously (this is the default).

              I'm presuming you have an external data store (such as a database) where you obtain your data, and use the cache as an im-memory store for cheap/easy access? If not (i.e., you use the cache loader to persist state to a shared DB) you could chain cache loaders:

              1) Use a local disk based cache loader (such as Oracle's Berkeley DB or jdbm Cache Loader) in sync mode (immediate flushes)
              2) JDBCCacheLoader pointing to your DB, in async mode.