2 Replies Latest reply on Jun 1, 2008 1:45 AM by beep_beep

    How I store objects in the cache. Trivial-not trivial?

    beep_beep

      Hi.

      This is probably a stupid question, but what can I do? I have that stupid problem...

      suppose we have 2 classes:
      1)

      package com.a;
      class A{
       int x;
       List<B> b;
      
      }

      2)
      package com.a;
      class B{
      
      
      
      }



      In short A is parent for collection of B.
      A is also multiplied(collection) in DB.


      Consider I produce a node, that created to hold objects of type A:

      Node rootNode = cache.getRoot();
       Fqn testEntityFqn = Fqn.fromString("/com/a/A");
       Node testEntity = rootNode.addChild(testEntityFqn);


      I put then A objects in this node:

      testEntity.put(id, objectA);



      Fine.

      But I ask myself and YOU:
      1. Why I've chosen to create separate node for collection of A?
      2. Why not separate node for each A in collection?
      3. Why not separate node for each A and separate node for each A primitive attribute(int x)?
      4. When I need cache B(that under A), what is my considerations: should I create separate node for each B, or one node for collection of Bs?

      5.Is there some guide line to HOW we store complex structures in the cache?
      6. If object A changed and I have eviction enabled in cluster, is it explicitly invalidates also Bs, that under that A? If B changed, does it cause invalidation of A? In what case it may happen?


      Thank you!!!
















        • 1. Re: How I store objects in the cache. Trivial-not trivial?
          manik

           

          "beep_beep" wrote:
          1. Why I've chosen to create separate node for collection of A?
          2. Why not separate node for each A in collection?
          3. Why not separate node for each A and separate node for each A primitive attribute(int x)?
          4. When I need cache B(that under A), what is my considerations: should I create separate node for each B, or one node for collection of Bs?

          5.Is there some guide line to HOW we store complex structures in the cache?
          6. If object A changed and I have eviction enabled in cluster, is it explicitly invalidates also Bs, that under that A? If B changed, does it cause invalidation of A? In what case it may happen?


          1. I don't know; why have you? :-)
          2. Could be done. If this is what you want.
          3. This is what POJO Cache does.
          4. Up to you, depending on your access patterns of B.
          5. Not yet. But it is a good idea to start one on the wiki.
          6. No, only a specific node is invalidated. If you are looking for invalidation of related objects, look at POJO Cache which will maintain object relationships.

          • 2. Re: How I store objects in the cache. Trivial-not trivial?
            beep_beep

            Nice!
            and thanks!