February 2015
Intermediate to advanced
170 pages
3h 39m
English
While the Couchbase SDKs have been written to be thread-safe, your Couchbase applications still must consider concurrency. Whether two users or two threads are attempting to modify the same key, locking is a necessity in order to limit stale data writes. Couchbase Server supports both pessimistic and optimistic locking.
The CRUD operations we've seen so far do not make use of any locking. To see why this is a problem, consider the following C# code:
public class Story
{
public String Title { get; set; }
public String Body { get; set; }
public List<String> Comments { get; set; }
}
var story = bucket.Get<Story>("story_slug").Value;
story.Comments.add("Nice Article!");
bucket.Replace<Story>("story_slug", story);Now suppose that ...
Read now
Unlock full access