Hi Folks,<br><br>I am trying to use memcached to store the relationships between persons ( So person A -&gt; Relationship Type -&gt; Person B )&nbsp; ( 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&nbsp; personID,relationshipType. <br>e.g<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map&lt;Integer,Integer&gt; relationMap = new HashMap&lt;Integer,Integer&gt;();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;  relationMap.put(1,1); .......<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcache.put( &quot;prefix&quot; + sourcePersonID ,&nbsp; 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>&nbsp;<br>&nbsp;&nbsp;&nbsp; Use both person IDs in the memcahe key.<br>&nbsp;&nbsp; e.g<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcache.put( &quot;prefix&quot; + sourcePersonID + &quot;:&quot;+ targetPersonID ,&nbsp; relationType);<br><br>In this case, there would be at max persons^2&nbsp; 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 -&gt; webapp )
<br><br>I would like to know which of option is better for my requirement ? <br><br>Thanks,<br>Rakesh<br>