JBoss Community

How to model data to be stored in JBoss Cache

created by Sanjit Mohanty in JBoss Cache - View the full discussion

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

Reply to this message by going to Community

Start a new discussion in JBoss Cache at Community