Dwight's blog
Prediction: Commutative DB Patterns Ahead

We will see a lot of commutative operators in eventually consistent datastores  a year from now.  It makes a lot of sense: we can then have some atomicity and still have the nice properties of eventual consistency.

Some example operators:

  • increment(field, by_n)
  • addToSet(field, value)

An example.  The final result is the same regardless of the order of operations:

// x starts as { }
x.increment('a', 1);
x.increment('a', 3);
x.addToSet('b', 'foo');
x.addToSet('b', 'bar');
result: { a : 4, b : {bar,foo} }
  1. dmerr posted this
blog comments powered by Disqus