-
1. Re: Who can tell me how to use jboss cache to store records
belaban Oct 25, 2004 7:57 AM (in response to guowenrui)"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
guowenrui Oct 25, 2004 9:28 PM (in response to guowenrui)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 Oct 26, 2004 2:17 AM (in response to guowenrui)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
guowenrui Oct 26, 2004 3:22 AM (in response to guowenrui)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.