0 Replies Latest reply: Aug 1, 2010 6:32 AM by Sanjit Mohanty RSS

    How to model data to be stored in JBoss Cache

    Sanjit Mohanty Newbie

      Hi,


      I understand JBoss cache internally stores data in a map i.e. in a key-value pair.
      So, incase i need to search for a data in the cache, i need to pass the key and i can retrieve the value.

       

      But what if, i need to retrieve key based on value!

       

      To clarify more on this, following is an example:

       

      Consider i want to store empId, deptId in JBoss cache.
          empId = unique employee ID
          deptId = department ID. A particular employee can be associated to multiple departments.

       

      I want to do following 2 things:
      (1) Get the deptIds based on an empId
      (2) Get the empIds based on a deptId

       


      Now, if i make empId as key & store deptId as it's value, then i can achieve (1) without any issues but it will be a problem for (2) because i need to do a full traversal of values, which is in-efficient!

       

      How should i model my data in this scenario?

       

      Thanks In advance!

       

      _Sanjit