Hi Folks,<br><br>I am trying to use memcached to store the relationships between persons ( So person A -> Relationship Type -> Person B ) ( Java based solution )<br><br>So given a person, I would need <br>1) To see if another person is a connection
<br>2) And the connection type.<br><br>As I see it, I could implement this in 2 ways<br><br><b>OPTION 1</b><br><br>For each user store a HashMap of personID,relationshipType. <br>e.g<br> Map<Integer,Integer> relationMap = new HashMap<Integer,Integer>();
<br> relationMap.put(1,1); .......<br><br> memcache.put( "prefix" + sourcePersonID , relationMap);<br><br>In this case, there would be as many keys in memcached, as there are persons.<br>
<br><br><b>OPTION 2</b><br> <br> Use both person IDs in the memcahe key.<br> e.g<br> memcache.put( "prefix" + sourcePersonID + ":"+ targetPersonID , relationType);<br><br>In this case, there would be at max persons^2 keys in memcahed.
<br><br><br><b>Assumptions</b><br>1) Each person would have an average of 200-300 friends<br>2) Memcahed would be on a different set of servers compared to the webapps ( So there would be a N/W delay in passing the data from memcached -> webapp )
<br><br>I would like to know which of option is better for my requirement ? <br><br>Thanks,<br>Rakesh<br>