class Collection (View source)

Collection is an object containing functionality for performing KeyValue operations against the server.

Methods

string
name()

Get the name of the collection.

get(string $id, GetOptions $options = null)

Gets a document from the server.

exists(string $id, ExistsOptions $options = null)

Checks if a document exists on the server.

getAndLock(string $id, int $lockTime, GetAndLockOptions $options = null)

Gets a document from the server, locking the document so that no other processes can perform mutations against it.

getAndTouch(string $id, int $expiry, GetAndTouchOptions $options = null)

Gets a document from the server and simultaneously updates its expiry time.

getAnyReplica(string $id, GetAnyReplicaOptions $options = null)

Gets a document from any replica server in the cluster.

array
getAllReplicas(string $id, GetAllReplicasOptions $options = null)

Gets a document from the active server and all replica servers in the cluster.

upsert(string $id, mixed $value, UpsertOptions $options = null)

Creates a document if it doesn't exist, otherwise updates it.

insert(string $id, mixed $value, InsertOptions $options = null)

Inserts a document if it doesn't exist, errors if it does exist.

replace(string $id, mixed $value, ReplaceOptions $options = null)

Replaces a document if it exists, errors if it doesn't exist.

remove(string $id, RemoveOptions $options = null)

Removes a document.

unlock(string $id, string $cas, UnlockOptions $options = null)

Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.

touch(string $id, int $expiry, TouchOptions $options = null)

Touches a document, setting a new expiry time.

lookupIn(string $id, array $specs, LookupInOptions $options = null)

Performs a set of subdocument lookup operations against the document.

mutateIn(string $id, array $specs, MutateInOptions $options = null)

Performs a set of subdocument lookup operations against the document.

array
getMulti(array $ids, RemoveOptions $options = null)

Retrieves a group of documents. If the document does not exist, it will not raise an exception, but rather fill non-null value in error() property of the corresponding result object.

array
removeMulti(array $entries, RemoveOptions $options = null)

Removes a group of documents. If second element of the entry (CAS) is null, then the operation will remove the document unconditionally.

array
upsertMulti(array $entries, UpsertOptions $options = null)

Creates a group of documents if they don't exist, otherwise updates them.

binary()

Creates and returns a BinaryCollection object for use with binary type documents.

Details

string name()

Get the name of the collection.

Return Value

string

GetResult get(string $id, GetOptions $options = null)

Gets a document from the server.

This can take 3 paths, a standard full document fetch, a subdocument full document fetch also fetching document expiry (when withExpiry is set), or a subdocument fetch (when projections are used).

Parameters

string $id

the key of the document to fetch

GetOptions $options

the options to use for the operation

Return Value

GetResult

ExistsResult exists(string $id, ExistsOptions $options = null)

Checks if a document exists on the server.

Parameters

string $id

the key of the document to check if exists

ExistsOptions $options

the options to use for the operation

Return Value

ExistsResult

GetResult getAndLock(string $id, int $lockTime, GetAndLockOptions $options = null)

Gets a document from the server, locking the document so that no other processes can perform mutations against it.

Parameters

string $id

the key of the document to get

int $lockTime

the length of time to lock the document in ms

GetAndLockOptions $options

the options to use for the operation

Return Value

GetResult

GetResult getAndTouch(string $id, int $expiry, GetAndTouchOptions $options = null)

Gets a document from the server and simultaneously updates its expiry time.

Parameters

string $id

the key of the document

int $expiry

the length of time to update the expiry to in ms

GetAndTouchOptions $options

the options to use for the operation

Return Value

GetResult

GetReplicaResult getAnyReplica(string $id, GetAnyReplicaOptions $options = null)

Gets a document from any replica server in the cluster.

Parameters

string $id

the key of the document

GetAnyReplicaOptions $options

the options to use for the operation

Return Value

GetReplicaResult

array getAllReplicas(string $id, GetAllReplicasOptions $options = null)

Gets a document from the active server and all replica servers in the cluster.

Returns an array of documents, one per server.

Parameters

string $id

the key of the document

GetAllReplicasOptions $options

the options to use for the operation

Return Value

array

MutationResult upsert(string $id, mixed $value, UpsertOptions $options = null)

Creates a document if it doesn't exist, otherwise updates it.

Parameters

string $id

the key of the document

mixed $value

the value to use for the document

UpsertOptions $options

the options to use for the operation

Return Value

MutationResult

MutationResult insert(string $id, mixed $value, InsertOptions $options = null)

Inserts a document if it doesn't exist, errors if it does exist.

Parameters

string $id

the key of the document

mixed $value

the value to use for the document

InsertOptions $options

the options to use for the operation

Return Value

MutationResult

MutationResult replace(string $id, mixed $value, ReplaceOptions $options = null)

Replaces a document if it exists, errors if it doesn't exist.

Parameters

string $id

the key of the document

mixed $value

the value to use for the document

ReplaceOptions $options

the options to use for the operation

Return Value

MutationResult

MutationResult remove(string $id, RemoveOptions $options = null)

Removes a document.

Parameters

string $id

the key of the document

RemoveOptions $options

the options to use for the operation

Return Value

MutationResult

Result unlock(string $id, string $cas, UnlockOptions $options = null)

Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.

Parameters

string $id

the key of the document

string $cas

the current cas value of the document

UnlockOptions $options

the options to use for the operation

Return Value

Result

MutationResult touch(string $id, int $expiry, TouchOptions $options = null)

Touches a document, setting a new expiry time.

Parameters

string $id

the key of the document

int $expiry

the expiry time for the document in ms

TouchOptions $options

the options to use for the operation

Return Value

MutationResult

LookupInResult lookupIn(string $id, array $specs, LookupInOptions $options = null)

Performs a set of subdocument lookup operations against the document.

Parameters

string $id

the key of the document

array $specs

the LookupInSpecs to perform against the document

LookupInOptions $options

the options to use for the operation

Return Value

LookupInResult

MutateInResult mutateIn(string $id, array $specs, MutateInOptions $options = null)

Performs a set of subdocument lookup operations against the document.

Parameters

string $id

the key of the document

array $specs

the MutateInSpecs to perform against the document

MutateInOptions $options

the options to use for the operation

Return Value

MutateInResult

array getMulti(array $ids, RemoveOptions $options = null)

Retrieves a group of documents. If the document does not exist, it will not raise an exception, but rather fill non-null value in error() property of the corresponding result object.

Parameters

array $ids

array of IDs, organized like this ["key1", "key2", ...]

RemoveOptions $options

the options to use for the operation

Return Value

array

array of GetResult, one for each of the entries

array removeMulti(array $entries, RemoveOptions $options = null)

Removes a group of documents. If second element of the entry (CAS) is null, then the operation will remove the document unconditionally.

Parameters

array $entries

array of arrays, organized like this [["key1", "encodedCas1"], ["key2", , "encodedCas2"], ...] or ["key1", "key2", ...]

RemoveOptions $options

the options to use for the operation

Return Value

array

array of MutationResult, one for each of the entries

array upsertMulti(array $entries, UpsertOptions $options = null)

Creates a group of documents if they don't exist, otherwise updates them.

Parameters

array $entries

array of arrays, organized like this [["key1", $value1], ["key2", $value2], ...]

UpsertOptions $options

the options to use for the operation

Return Value

array

array of MutationResult, one for each of the entries

BinaryCollection binary()

Creates and returns a BinaryCollection object for use with binary type documents.

Return Value

BinaryCollection