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.
-
rc
¶ libcouchbase error code
-
success
¶ Determine whether operation succeeded or not
-
errstr
¶ Returns a textual representation of the error
-
key
¶ 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
¶ CAS For the key
-
value
¶ Value for the operation
-
-
class
couchbase.result.
HttpResult
¶ Bases:
Result
Generic object returned for HTTP operations
-
done
¶ If the result is done
-
headers
¶ Headers dict for the request.
-
http_status
¶ HTTP Status Code
-
success
¶ Whether the HTTP request was successful
-
url
¶ HTTP URI
-
value
¶ 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 likequiet
was passed toget_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 errorUsing 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)
-
all_ok
¶ Whether all the items in this result are successful
-
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¶
-
class
couchbase.result.
ObserveInfo
¶ Object containing information about a key’s OBSERVED state
-
cas
¶ 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
)
-
flags
¶ Server-side flags received from observe
-
from_master
¶ Whether this response is from the master node. This evaluates to False if this status is from a replica
-