couchbase/couchbase-ruby-client — pull request #16 by scottwb (2013-11-14 18:40:08+00:00)
Title: Extend Couchbase::Bucket#cas to support a `:retry` option.

This allows the caller to specify a maximum number of times to retry the entire get/update/set operation in the event of a concurrent update collision between the get and the set. This effectively eliminates the need for the separate `#update_with_retry` method that I use for optimistic locking, which I blogged about and discussed with @avsej here: http://scottwb.com/blog/2013/11/11/optimistic-locking-with-couchbase-and-ruby/

You may want to cherry-pick the commits ala carte. The last commit is the real meat. The first one is discardable as it was only there to assist in development, and the second commit merely adds some additional test coverage to existing behavior -- take it or leave it.