Result Objects

This is the base class for all result operations

class couchbase.result.Result

The standard return type for Couchbase operations.

This is a lightweight object and may be subclassed by other operations which may required additional fields.


libcouchbase error code


Determine whether operation succeeded or not


Returns a textual representation of the error


Key for the operation

class couchbase.result.OperationResult

Bases: Result

Result type returned for operations which do not fetch data

class couchbase.result.ValueResult

Bases: OperationResult

The result type returned for operations which retrieve a value


CAS For the key


Flags for the value


Value for the operation

class couchbase.result.HttpResult

Bases: Result

Generic object returned for HTTP operations


If the result is done


Headers dict for the request.


HTTP Status Code


Whether the HTTP request was successful




HTTP Payload

class couchbase.result.MultiResult

This class is intended to serve as a container for multiple results returned from an operation. It is a subclass of dict and may be used as such. The keys will be the keys on which the operations were performed and the values will be the results of the operation (i.e. a OperationResult object)

The all_ok field can be used to quickly examine the object for errors (in case something like quiet was passed to get_multi()), e.g.

Using the all_ok field:

results = cb.get_multi(("foo", "bar", "baz"), quiet=True)
if not results.all_ok:
    # process error handling here
    print "Some results did not complete successfully"

If an exception is propagated during the operation, the MultiResult class will still contain valid contents, except than being a return value, it will be available via the thrown exceptions’ all_results field. From this field you can inspect the non-failed operations and handle them as approrpiate, while only invoking error handling for those items which explicitly contained an error

Using the MultiResult class from an exception handler:

except CouchbaseDataError as e:
    for key, result in e.all_results.items():
        if not result.success:
            print "Could not add {0}. Got error code {1}".format(key, result.rc)

Whether all the items in this result are successful

Observe Results

Observe Constants

These constants are returned as values for ObserveInfo.flags field.


The key exists on the given node’s cache, though it may not have been stored to disk yet.


The key is persisted to the given node’s disk.


The key is not present in the node’s cache.


The key is not present in the node’s cache, however it is still present on the persistent store. If the node would crash at this moment, the key would still be present when it starts up again.

This is equivalent to OBS_NOTFOUND | OBS_PERSISTED

ObserveInfo Object

class couchbase.result.ObserveInfo

Object containing information about a key’s OBSERVED state


CAS as it exists on the given node. It is possible (though not likely) that different nodes will have a different CAS value for a given key. In this case, the actual CAS being used should be the one from the master (use from_master)


Server-side flags received from observe


Whether this response is from the master node. This evaluates to False if this status is from a replica