Redis Snippet for Storing the Social Graph
We are leaving the Twitter, Facebook days, so a couple of days ago we were looking at two examples of storing friend lists in Redis and MySQL and wondering which one is simpler. Eric Florenzano (@ericflo) shared a Gist exemplifying storing a simple social graph in Redis:
The example uses a bidirectional relationship: if A is B’s friend, then B is A’s friend. Note that due to Redis lack of transactions this code will not guarantee that both sides of the relationship are persisted. A better approach for this scenario would be using Redis MULTI/EXEC, which while not really a transaction would guarantee that both operations are performed together server side.
Original title and link for this post: Redis Snippet for Storing the Social Graph (published on the NoSQL blog: myNoSQL)