class Bucket (View source)

Represents connection to the Couchbase Server

Constants

PINGSVC_KV

Ping data (Key/Value) service.

PINGSVC_N1QL

Ping query (N1QL) service.

PINGSVC_VIEWS

Ping views (Map/Reduce) service.

PINGSVC_FTS

Ping full text search (FTS) service.

Properties

int $operationTimeout

The operation timeout (in microseconds) is the maximum amount of time the library will wait for an operation to receive a response before invoking its callback with a failure status.

An operation may timeout if:

  • A server is taking too long to respond
  • An updated cluster configuration has not been promptly received
int $viewTimeout

The I/O timeout (in microseconds) for HTTP requests to Couchbase Views API

int $n1qlTimeout

The I/O timeout (in microseconds) for N1QL queries.

int $httpTimeout

The I/O timeout (in microseconds) for HTTP queries (management API).

int $configTimeout

How long (in microseconds) the client will wait to obtain the initial configuration.

int $configNodeTimeout

Per-node configuration timeout (in microseconds).

This timeout sets the amount of time to wait for each node within the bootstrap/configuration process. This interval is a subset of the $configTimeout option mentioned above and is intended to ensure that the bootstrap process does not wait too long for a given node. Nodes that are physically offline may never respond and it may take a long time until they are detected as being offline.

int $configDelay

Config refresh throttling

Modify the amount of time (in microseconds) before the configiration error threshold will forcefully be set to its maximum number forcing a configuration refresh.

Note that if you expect a high number of timeouts in your operations, you should set this to a high number. If you are using the default timeout setting, then this value is likely optimal.

int $htconfigIdleTimeout

Idling/Persistence for HTTP bootstrap (in microseconds)

By default the behavior of the library for HTTP bootstrap is to keep the stream open at all times (opening a new stream on a different host if the existing one is broken) in order to proactively receive configuration updates.

The default value for this setting is -1. Changing this to another number invokes the following semantics:

  • The configuration stream is not kept alive indefinitely. It is kept open for the number of seconds specified in this setting. The socket is closed after a period of inactivity (indicated by this setting).

  • If the stream is broken (and no current refresh was requested by the client) then a new stream is not opened.

int $durabilityInterval

The time (in microseconds) the client will wait between repeated probes to a given server.

int $durabilityTimeout

The time (in microseconds) the client will spend sending repeated probes to a given key's vBucket masters and replicas before they are deemed not to have satisfied the durability requirements

Methods

string
getName()

Returns the name of the bucket for current connection

manager()

Returns an instance of a CouchbaseBucketManager for performing management operations against a bucket.

setTranscoder(callable $encoder, callable $decoder)

Sets custom encoder and decoder functions for handling serialization.

Document|array
get(string|array $ids, array $options = [])

Retrieves a document

Document|array
getAndLock(string|array $ids, int $lockTime, array $options = [])

Retrieves a document and locks it.

Document|array
getAndTouch(string|array $ids, int $expiry, array $options = [])

Retrieves a document and updates its expiration time.

Document|array
getFromReplica(string|array $ids, array $options = [])

Retrieves a document from a replica.

Document|array
upsert(string|array $ids, mixed $value, array $options = [])

Inserts or updates a document, depending on whether the document already exists on the cluster.

Document|array
insert(string|array $ids, mixed $value, array $options = [])

Inserts a document. This operation will fail if the document already exists on the cluster.

Document|array
replace(string|array $ids, mixed $value, array $options = [])

Replaces a document. This operation will fail if the document does not exists on the cluster.

Document|array
append(string|array $ids, mixed $value, array $options = [])

Appends content to a document.

Document|array
prepend(string|array $ids, mixed $value, array $options = [])

Prepends content to a document.

Document|array
remove(string|array $ids, array $options = [])

Removes the document.

Document|array
unlock(string|array $ids, array $options = [])

Unlocks previously locked document

Document|array
touch(string|array $ids, int $expiry, array $options = [])

Updates document's expiration time.

Document|array
counter(string|array $ids, int $delta = 1, array $options = [])

Increments or decrements a key (based on $delta)

lookupIn(string $id)

Returns a builder for reading subdocument API.

retrieveIn(string $id, string ...$paths)

Retrieves specified paths in JSON document

mutateIn(string $id, string $cas)

Returns a builder for writing subdocument API.

object
query(N1qlQuery|ViewQuery|SpatialViewQuery|SearchQuery|AnalyticsQuery $query, bool $jsonAsArray = false)

Performs a query to Couchbase Server

int
mapSize(string $id)

Returns size of the map

mapAdd(string $id, string $key, mixed $value)

Add key to the map

mapRemove(string $id, string $key)

Removes key from the map

mixed
mapGet(string $id, string $key)

Get an item from a map

int
setSize(string $id)

Returns size of the set

setAdd(string $id, string|int|float|bool $value)

Add value to the set

bool
setExists(string $id, string|int|float|bool $value)

Check if the value exists in the set

setRemove(string $id, string|int|float|bool $value)

Remove value from the set

int
listSize(string $id)

Returns size of the list

listPush(string $id, mixed $value)

Add an element to the end of the list

listShift(string $id, mixed $value)

Add an element to the beginning of the list

listRemove(string $id, int $index)

Remove an element at the given position

mixed
listGet(string $id, int $index)

Get an element at the given position

listSet(string $id, int $index, mixed $value)

Set an element at the given position

bool
listExists(string $id, mixed $value)

Check if the list contains specified value

int
queueSize(string $id)

Returns size of the queue

bool
queueExists(string $id, mixed $value)

Checks if the queue contains specified value

queueAdd(string $id, mixed $value)

Add an element to the beginning of the queue

mixed
queueRemove(string $id)

Remove the element at the end of the queue and return it

array
ping(int $services = 0, string $reportId = null)

Try to reach specified services, and measure network latency.

array
diag(string $reportId = null)

Collect and return information about state of internal network connections.

array
encryptFields(array $document, array $fieldOptions, string $prefix = null)

Encrypt fields inside specified document.

array
decryptFields(array $document, array $fieldOptions, string $prefix = null)

Decrypt fields inside specified document.

Details

string getName()

Returns the name of the bucket for current connection

Return Value

string

BucketManager manager()

Returns an instance of a CouchbaseBucketManager for performing management operations against a bucket.

Return Value

BucketManager

setTranscoder(callable $encoder, callable $decoder)

Sets custom encoder and decoder functions for handling serialization.

Parameters

callable $encoder
callable $decoder

See also

defaultEncoder
defaultDecoder
passthruEncoder
passthruDecoder

Document|array get(string|array $ids, array $options = [])

Retrieves a document

Parameters

string|array $ids

one or more IDs

array $options

options

  • "lockTime" non zero if the documents have to be locked
  • "expiry" non zero if the expiration time should be updated
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

Bucket::getAndLock
Bucket::getAndTouch
Bucket::unlock
Bucket::touch
https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array getAndLock(string|array $ids, int $lockTime, array $options = [])

Retrieves a document and locks it.

After the document has been locked on the server, its CAS would be masked, and all mutations of it will be rejected until the server unlocks the document automatically or it will be done manually with \Couchbase\Bucket::unlock() operation.

Parameters

string|array $ids

one or more IDs

int $lockTime

time to lock the documents

array $options

options

  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

Bucket::unlock
https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK
https://forums.couchbase.com/t/is-there-a-way-to-do-pessimistic-locking-for-more-than-30-seconds/10666/3 Forum post about getting server defaults for the $lockTime

Document|array getAndTouch(string|array $ids, int $expiry, array $options = [])

Retrieves a document and updates its expiration time.

Parameters

string|array $ids

one or more IDs

int $expiry

time after which the document will not be accessible. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).

array $options

options

  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array getFromReplica(string|array $ids, array $options = [])

Retrieves a document from a replica.

Parameters

string|array $ids

one or more IDs

array $options

options

  • "index" the replica index. If the index is zero, it will return first successful replica, otherwise it will read only selected node.
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK
https://developer.couchbase.com/documentation/server/current/sdk/php/failure-considerations.html More about failure considerations.

Document|array upsert(string|array $ids, mixed $value, array $options = [])

Inserts or updates a document, depending on whether the document already exists on the cluster.

Parameters

string|array $ids

one or more IDs

mixed $value

value of the document

array $options

options

  • "expiry" document expiration time in seconds. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "persist_to" how many nodes the key should be persisted to (including master). If set to 0 then persistence will not be checked. If set to a negative number, will be set to the maximum number of nodes to which persistence is possible (which will always contain at least the master node).
  • "replicate_to" how many nodes the key should be persisted to (excluding master). If set to 0 then replication will not be checked. If set to a negative number, will be set to the maximum number of nodes to which replication is possible (which may be 0 if the bucket is not configured for replicas).
  • "flags" override flags (not recommended to use)
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array insert(string|array $ids, mixed $value, array $options = [])

Inserts a document. This operation will fail if the document already exists on the cluster.

Parameters

string|array $ids

one or more IDs

mixed $value

value of the document

array $options

options

  • "expiry" document expiration time in seconds. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "persist_to" how many nodes the key should be persisted to (including master). If set to 0 then persistence will not be checked. If set to a negative number, will be set to the maximum number of nodes to which persistence is possible (which will always contain at least the master node).
  • "replicate_to" how many nodes the key should be persisted to (excluding master). If set to 0 then replication will not be checked. If set to a negative number, will be set to the maximum number of nodes to which replication is possible (which may be 0 if the bucket is not configured for replicas).
  • "flags" override flags (not recommended to use)
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array replace(string|array $ids, mixed $value, array $options = [])

Replaces a document. This operation will fail if the document does not exists on the cluster.

Parameters

string|array $ids

one or more IDs

mixed $value

value of the document

array $options

options

  • "cas" last known document CAS, which serves for optimistic locking.
  • "expiry" document expiration time in seconds. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "persist_to" how many nodes the key should be persisted to (including master). If set to 0 then persistence will not be checked. If set to a negative number, will be set to the maximum number of nodes to which persistence is possible (which will always contain at least the master node).
  • "replicate_to" how many nodes the key should be persisted to (excluding master). If set to 0 then replication will not be checked. If set to a negative number, will be set to the maximum number of nodes to which replication is possible (which may be 0 if the bucket is not configured for replicas).
  • "flags" override flags (not recommended to use)
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array append(string|array $ids, mixed $value, array $options = [])

Appends content to a document.

On the server side it just contatenate passed value to the existing one. Note that this might make the value un-decodable. Consider sub-document API for partial updates of the JSON documents.

Parameters

string|array $ids

one or more IDs

mixed $value

value of the document

array $options

options

  • "cas" last known document CAS, which serves for optimistic locking.
  • "expiry" document expiration time in seconds. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "persist_to" how many nodes the key should be persisted to (including master). If set to 0 then persistence will not be checked. If set to a negative number, will be set to the maximum number of nodes to which persistence is possible (which will always contain at least the master node).
  • "replicate_to" how many nodes the key should be persisted to (excluding master). If set to 0 then replication will not be checked. If set to a negative number, will be set to the maximum number of nodes to which replication is possible (which may be 0 if the bucket is not configured for replicas).
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

Bucket::mutateIn
https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array prepend(string|array $ids, mixed $value, array $options = [])

Prepends content to a document.

On the server side it just contatenate existing value to the passed one. Note that this might make the value un-decodable. Consider sub-document API for partial updates of the JSON documents.

Parameters

string|array $ids

one or more IDs

mixed $value

value of the document

array $options

options

  • "cas" last known document CAS, which serves for optimistic locking.
  • "expiry" document expiration time in seconds. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "persist_to" how many nodes the key should be persisted to (including master). If set to 0 then persistence will not be checked. If set to a negative number, will be set to the maximum number of nodes to which persistence is possible (which will always contain at least the master node).
  • "replicate_to" how many nodes the key should be persisted to (excluding master). If set to 0 then replication will not be checked. If set to a negative number, will be set to the maximum number of nodes to which replication is possible (which may be 0 if the bucket is not configured for replicas).
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

Bucket::mutateIn
https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array remove(string|array $ids, array $options = [])

Removes the document.

Parameters

string|array $ids

one or more IDs

array $options

options

  • "cas" last known document CAS, which serves for optimistic locking.
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array unlock(string|array $ids, array $options = [])

Unlocks previously locked document

Parameters

string|array $ids

one or more IDs

array $options

options

  • "cas" last known document CAS, which has been returned by locking command.
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

Bucket::get
Bucket::getAndLock
https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array touch(string|array $ids, int $expiry, array $options = [])

Updates document's expiration time.

Parameters

string|array $ids

one or more IDs

int $expiry

time after which the document will not be accessible. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).

array $options

options

  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

Document|array counter(string|array $ids, int $delta = 1, array $options = [])

Increments or decrements a key (based on $delta)

Parameters

string|array $ids

one or more IDs

int $delta

the number whih determines the sign (positive/negative) and the value of the increment

array $options

options

  • "initial" initial value of the counter if it does not exist
  • "expiry" time after which the document will not be accessible. If larger than 30 days (606024*30), it will be interpreted by the server as absolute UNIX time (seconds from epoch 1970-01-01T00:00:00).
  • "groupid" override value for hashing (not recommended to use)

Return Value

Document|array

document or list of the documents

See also

https://developer.couchbase.com/documentation/server/current/sdk/core-operations.html Overview of K/V operations
https://developer.couchbase.com/documentation/server/current/sdk/php/document-operations.html More details about K/V operations for PHP SDK

LookupInBuilder lookupIn(string $id)

Returns a builder for reading subdocument API.

Parameters

string $id

The ID of the JSON document

Return Value

LookupInBuilder

See also

https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

DocumentFragment retrieveIn(string $id, string ...$paths)

Retrieves specified paths in JSON document

This is essentially a shortcut for lookupIn($id)->get($paths)->execute().

Parameters

string $id

The ID of the JSON document

string ...$paths

List of the paths inside JSON documents (see "Path syntax" section of the "Sub-Document Operations" documentation).

Return Value

DocumentFragment

See also

https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

MutateInBuilder mutateIn(string $id, string $cas)

Returns a builder for writing subdocument API.

Parameters

string $id

The ID of the JSON document

string $cas

Last known document CAS value for optimisti locking

Return Value

MutateInBuilder

See also

https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

object query(N1qlQuery|ViewQuery|SpatialViewQuery|SearchQuery|AnalyticsQuery $query, bool $jsonAsArray = false)

Performs a query to Couchbase Server

Parameters

N1qlQuery|ViewQuery|SpatialViewQuery|SearchQuery|AnalyticsQuery $query
bool $jsonAsArray

if true, the values in the result rows (or hits) will be represented as PHP arrays, otherwise they will be instances of the stdClass

Return Value

object

Query-specific result object.

See also

N1qlQuery
SearchQuery
ViewQuery
SpatialViewQuery

int mapSize(string $id)

Returns size of the map

Parameters

string $id

ID of the document

Return Value

int

number of the key-value pairs

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

mapAdd(string $id, string $key, mixed $value)

Add key to the map

Parameters

string $id

ID of the document

string $key key
mixed $value value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

mapRemove(string $id, string $key)

Removes key from the map

Parameters

string $id

ID of the document

string $key key

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

mixed mapGet(string $id, string $key)

Get an item from a map

Parameters

string $id

ID of the document

string $key key

Return Value

mixed

value associated with the key

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

int setSize(string $id)

Returns size of the set

Parameters

string $id

ID of the document

Return Value

int

number of the elements

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

setAdd(string $id, string|int|float|bool $value)

Add value to the set

Note, that currently only primitive values could be stored in the set (strings, integers and booleans).

Parameters

string $id

ID of the document

string|int|float|bool $value

new value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

bool setExists(string $id, string|int|float|bool $value)

Check if the value exists in the set

Parameters

string $id

ID of the document

string|int|float|bool $value

value to check

Return Value

bool

true if the value exists in the set

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

setRemove(string $id, string|int|float|bool $value)

Remove value from the set

Parameters

string $id

ID of the document

string|int|float|bool $value

value to remove

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

int listSize(string $id)

Returns size of the list

Parameters

string $id

ID of the document

Return Value

int

number of the elements

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

listPush(string $id, mixed $value)

Add an element to the end of the list

Parameters

string $id

ID of the document

mixed $value

new value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

listShift(string $id, mixed $value)

Add an element to the beginning of the list

Parameters

string $id

ID of the document

mixed $value

new value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

listRemove(string $id, int $index)

Remove an element at the given position

Parameters

string $id

ID of the document

int $index

index of the element to be removed

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

mixed listGet(string $id, int $index)

Get an element at the given position

Parameters

string $id

ID of the document

int $index

index of the element

Return Value

mixed

the value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

listSet(string $id, int $index, mixed $value)

Set an element at the given position

Parameters

string $id

ID of the document

int $index

index of the element

mixed $value

new value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

bool listExists(string $id, mixed $value)

Check if the list contains specified value

Parameters

string $id

ID of the document

mixed $value

value to look for

Return Value

bool

true if the list contains the value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

int queueSize(string $id)

Returns size of the queue

Parameters

string $id

ID of the document

Return Value

int

number of the elements in the queue

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

bool queueExists(string $id, mixed $value)

Checks if the queue contains specified value

Parameters

string $id

ID of the document

mixed $value

value to look for

Return Value

bool

true if the queue contains the value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

queueAdd(string $id, mixed $value)

Add an element to the beginning of the queue

Parameters

string $id

ID of the document

mixed $value

new value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

mixed queueRemove(string $id)

Remove the element at the end of the queue and return it

Parameters

string $id

ID of the document

Return Value

mixed

removed value

See also

https://developer.couchbase.com/documentation/server/current/sdk/php/datastructures.html More details on Data Structures
https://developer.couchbase.com/documentation/server/current/sdk/subdocument-operations.html Overview of Sub-Document Operations

array ping(int $services = 0, string $reportId = null)

Try to reach specified services, and measure network latency.

Parameters

int $services

bitwise mask of required services (and all services when zero)

string $reportId

custom identifier, which will be appended to "id" property in report

Return Value

array

the report object

See also

Bucket::PINGSVC_KV
Bucket::PINGSVC_N1QL
Bucket::PINGSVC_VIEWS
Bucket::PINGSVC_FTS
https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0034-health-check.md SDK RFC #34, which describes the feature and report layout.

array diag(string $reportId = null)

Collect and return information about state of internal network connections.

Parameters

string $reportId

custom identifier, which will be appended to "id" property in report

Return Value

array

the report object

See also

https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0034-health-check.md SDK RFC #34, which describes the feature and report layout.

array encryptFields(array $document, array $fieldOptions, string $prefix = null)

Encrypt fields inside specified document.

Parameters

array $document

document structure

array $fieldOptions

specification for fields needed to be encrypted. Where 'alg' contains a string with alias of the registed crypto provider, and 'name' contains the name of the field.

string $prefix

optional prefix for modified field (when null, the library will use "__crypt")

Return Value

array

where the fields encrypted

See also

https://github.com/couchbase/php-couchbase-encryption

array decryptFields(array $document, array $fieldOptions, string $prefix = null)

Decrypt fields inside specified document.

Parameters

array $document

document structure

array $fieldOptions

specification for fields needed to be decrypted. Where 'alg' contains a string with alias of the registed crypto provider, and 'name' contains the name of the field.

string $prefix

optional prefix for modified field (when null, the library will use "__crypt")

Return Value

array

where the fields decrypted

See also

https://github.com/couchbase/php-couchbase-encryption