Storage Plan: Map v/s linear
rakeshxp at gmail.com
Sat Nov 10 12:14:16 UTC 2007
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
For each user store a HashMap of personID,relationshipType.
Map<Integer,Integer> relationMap = new
memcache.put( "prefix" + sourcePersonID , relationMap);
In this case, there would be as many keys in memcached, as there are
Use both person IDs in the memcahe key.
memcache.put( "prefix" + sourcePersonID + ":"+ targetPersonID ,
In this case, there would be at max persons^2 keys in memcahed.
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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the memcached