4 Replies Latest reply on Oct 26, 2004 3:22 AM by Guo WenRui

    Who can tell me how to use jboss cache to store records retr

    Guo WenRui Newbie

      Recently, I use jboss cache to act as a middle part which store records retrieved from rdbms, and I wondered the best way to do that. You know, we usually sotre records as an entry in hashmap, but the jboss cache is a tree structure. Using jboss cache like a hashmap is meaningless. Who can help me?

      Thanks & Best regards.

        • 1. Re: Who can tell me how to use jboss cache to store records
          Bela Ban Master

           

          "guowenrui" wrote:
          Using jboss cache like a hashmap is meaningless


          Absolutely not; TreeCache can be used as a replicated hashtable, without any performance penalty.

          Bela

          • 2. Re: Who can tell me how to use jboss cache to store records
            Guo WenRui Newbie

            Bela, I also agree on that. Though TreeCache is a replicated hashtable, but how i can use it as a really tree. The most difficult thing i encounted is how to transform one record to multiple nodes under the root.

            • 3. Re: Who can tell me how to use jboss cache to store records
              Norbert von Truchsess Newbie

              You are free in your decision how to map your 'keys' to the tree-structure that TreeCache provides. You may also decide not to use the Tree-structure and store all Records as Key-value-pairs in a single Node.

              Keep in mind that locking is taking place on node-level. And the kind of lock being used depends on the transaction-isolation-level.

              Every time you put a key-value-pair into a node locking takes place.

              Every time you create or remove a node locking also takes place (on the parent node).

              The kind of lock being used depends on the transaction-isolation-level. If you specify REPEATABLE_READ or SERIALIZABLE, the nodes in question are write-locked for the time of your transaction read-access is blocked during this time. If you use a lower isolation-level nodes may be accessed from within multiple transactions in paralell and the use of transactions does not have a negative performance-impact (as a drawback it's not garanteed you will allways retrive the same value during the transaction because another thread might have altered the data in the meantime).

              Because of this I'd recommend you map your keys to the last entry in the FQNs being used if you have to use at least REPEATABLE_READ. If a lower isolation-level is sufficient using a single node and putting all data into it like a regular hashtable will perform slighly better.

              • 4. Re: Who can tell me how to use jboss cache to store records
                Guo WenRui Newbie

                Thanks to bela and norbert. I got it.

                norbert remind me of the lock mechanism. Yes, If I put all record s into a node under the root, then when I read or remove some keys & values from the data node, then the whole node will be locked, that's a bad thing. So if I put every record into its own node which Fqn is maked up of primary key of it, then every time I get/put/remove the node, the lock will only be acquired on the node and its parents, but the others will not be affected.