The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Couchbase::Client::Return - Common return datatype for Couchbase

DESCRIPTION

This is the common datatype for couchbase operations. Each operation (e.g. get, set etc.) will typically have complex return types to facilitate various types of errors and status reports.

The object is implemented as a simple array whose constants are available in Couchbase::Client::IDXConst if performance is an issue for calling the methods

FIELDS

errnum
is_ok

errnum is the Couchbase specific error code indicating stataus. An operation is successful if errnum is equal to COUCHBASE_SUCCESS.

The is_ok function does this check internally, and will probably look nicer in your code.

Some error definitions and explanations can be found in Couchbase::Client::Errors

errstr

A human-readable representation of errnum

value

only valid for get operations

The returned value for the request. If this is undef it might be advisable to check error status.

cas

only valid for get operations

The opaque CAS item used for atomic updates.

While the protocol itself defines CAS as a <unit64_t>, in perl it is stored as the equivalent of a pack("Q", $casval) (this is not the actual code used, but an unpack("Q", $casval) will yield the numeric value)

CAS values will always be returned for get-like functions.

<ERRNAME>

Some nice magic in this module.

Instead of doing this:

    if($ret->errnum == COUCHBASE_KEY_EEXISTS) {
        ...
    }
    

you can do this

    if($ret->KEY_EEXISTS) {
        ...
    }
    
    

In other words, you can call any error 'basename' (that is, the error without the COUCHBASE_ prefix) as a method on this object, and its return value will be a boolean indicating whether errnum is equal to COUCHBASE_$name