database - What is CAS in nosql and how to use it? -


write operations on coucbahse accepts parameter cas (create , set). return result object of non-data fetching query has cas property in it. googled bit , couldn't found conceptual article it.

could tell me when use cas , how it? should common work-flow of using cas?

my guess need fetch cas first write operation , pass along next write. need update using result's cas. correct me if wrong.

cas stands check-and-set, , method of optimistic locking. cas value or id associated each document updated whenever document changes - bit revision id. intent instead of pessimistically locking document (and associated lock overhead) read it's cas value, , perform write if cas matches.

the general use-case is:

  1. read existing document, , obtain it's current cas (get_with_cas)
  2. prepare new value document, assuming no-one else has modified document (and hence caused cas change).
  3. write document using check_and_set operation, providing cas value (1).

step 3 succeed (perform write) if document unchanged between (1) , (3) - i.e. no other user has modified in meantime. typically if (3) fail retry whole sequence (get_with_cas, modify, check_and_set).

there's more detailed description of check-and-set in couchbase developer guide under check , set (cas).


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -