Result Objects

This is the base class for all result operations

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:

try:
    cb.insert({"foo":"fooval","bar":"barval"})
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)

Observe Results

Observe Constants

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

couchbase.OBS_FOUND

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

couchbase.OBS_PERSISTED

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

couchbase.OBS_NOTFOUND

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

couchbase.OBS_LOGICALLY_DELETED

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