Search:

Search all manuals
Search this manual
Manual
Couchbase Developer's Guide 1.8
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
Couchbase Developer's Guide 1.8
Child Sections
Chapters

Chapter 7. Developing a Client Library

Table of Contents

7.1. Providing SASL Authentication
7.1.1. List Mechanisms
7.1.2. Making an Authentication Request
7.2. Handling REST/JSON
7.2.1. Parsing the JSON
7.2.2. Handling vBucketMap Information
7.2.3. Encoding the vBucketId
7.2.4. Handling Rebalances in Your Client Library
7.2.5. Fast Forward Map
7.2.6. Redundancy & Availability
7.3. Couchbase Protocol Extensions

This chapter is relevant for developers who are creating their own client library that communicates with the Couchbase Server. For instance, developers creating a library for language or framework that is not yet supported by Couchbase would be interested in this content.

Couchbase SDKs provide an abstraction layer your web application will use to communicate with a cluster. Your application logic does not need to contain logic about navigating information in a cluster, nor does it need much additional code for handling data requests.

Once your client makes calls into your client library the following should be handled automatically at the SDK level:

In general, your Couchbase client library implemention will be similar to a memcached(binary protocol) client library implementation.

For instance, it may even be an extension of some existing memcached binary-protocol client library), but just supports a different key hashing approach. Instead of using modulus or ketama/consistent hashing, the new hashing approach in Couchbase is instead based around "vbuckets", which you can read up more about here

In the vBucket approach, to find a server to talk to for a given key, your client library should hash the key string into a vBucket-Id (a 16-bit integer). The default hash algorithm for this step is plain CRC, masked by the required number of bits. The vBucket-Id is then used as an array index into a server lookup table, which is also called a vBucket-to-server map. Those two steps will allow your client library to find the right couchbase server given a key and a vBucket-to-server map. This extra level of indirection (where we have an explicit vBucket-to-server map) allows couchbase to easily control item data rebalancing, migration and replication.