Reading and writing data

In general, all Couchbase SDKs provide the same core set of methods to read, write and update documents in the Couchbase Server’s data stores. Common features across all SDKs include:

All operations are atomic

All operations require a key

No implicit locking, such as a row lock, occur during an operation

Several update operations require a matching CAS value in order to succeed. You provide the CAS value as a parameter to a method and if the value matches the current CAS value stored with a document, it will be updated.

The following describes major data store operations you can perform in your web application using the Couchbase Client. Language-specific variations in the SDK’s do exist; please consult your chosen SDK’s Language Reference for details specific to the SDK at Develop with Couchbase .

Note: If you use the text-based memcache protocol to communicate with Couchbase Server, you will need to use moxi as a message proxy. For more information, see Moxi Manual 1.8 .

Store Operations

Add: Stores a given document if it does not yet exist in the data store.

Set: Stores a given document, overwriting an existing version if it exists.

Retrieve Operations

Get: Retrieve/Fetch a specified document.

Get and touch: Fetch a specified document and update the document expiration.

Multi-retrieves: Fetch multiple documents in a single server request.

Update Operations

Touch: Update the Time to Live (TTL) for a given document.

Replace: Replace a given document, if it exists, otherwise do not commit any data to the store.

Compare and swap (CAS): Replace a current document with a given document if it matches a given CAS value.

Append/Prepend: Add data at the start, or at the end of a specified document.