Storage Plan: Map v/s linear
Rakesh Rajan
rakeshxp at gmail.com
Sat Nov 10 12:14:16 UTC 2007
Hi Folks,
I am trying to use memcached to store the relationships between persons ( So
person A -> Relationship Type -> Person B ) ( Java based solution )
So given a person, I would need
1) To see if another person is a connection
2) And the connection type.
As I see it, I could implement this in 2 ways
*OPTION 1*
For each user store a HashMap of personID,relationshipType.
e.g
Map<Integer,Integer> relationMap = new
HashMap<Integer,Integer>();
relationMap.put(1,1); .......
memcache.put( "prefix" + sourcePersonID , relationMap);
In this case, there would be as many keys in memcached, as there are
persons.
*OPTION 2*
Use both person IDs in the memcahe key.
e.g
memcache.put( "prefix" + sourcePersonID + ":"+ targetPersonID ,
relationType);
In this case, there would be at max persons^2 keys in memcahed.
*Assumptions*
1) Each person would have an average of 200-300 friends
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 )
I would like to know which of option is better for my requirement ?
Thanks,
Rakesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20071110/28c55be4/attachment.html
More information about the memcached
mailing list