Why a plain cache does not fit a graph

video locked
Enroll to watch

4 mins

Chapters
About
Discussion0
Notes
Be the first to start a conversation!

A simple cache like memcached is a key value store, and a graph kept in it loads whole lists and brings concepts irrelevant to graph operations.

  1. Edge lists. Every load operation fetches the entire list. Gaurav has almost 5 thousand friends, so showing them brings 5 thousand people into the cache.
  2. One edge. To know whether Pankaj liked a post, the post is the key and the whole array of likes is loaded into memory.
  3. Concurrent updates. Pankaj likes the post while Sanchit dislikes it, and one array has to allow both. A mismatch needs optimistic locking, pessimistic locking or a merge.
  4. Consistency. Memcached ensures it with leases and remote markers. An operation of one or two steps in a graph is three or four in a key value store.

TAO is a library over memcached with its own data model of objects and interactions, and it takes care of the cache and the database in the background.

There is no real efficiency gain. Engineers think in graph models and not in key value models.