Documentation

Collection
in package

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

Table of Contents

binary()  : BinaryCollection
Creates and returns a BinaryCollection object for use with binary type documents.
exists()  : ExistsResult
Checks if a document exists on the server.
get()  : GetResult
Gets a document from the server.
getAllReplicas()  : array<string|int, mixed>
Gets a document from the active server and all replica servers in the cluster.
getAndLock()  : GetResult
Gets a document from the server, locking the document so that no other processes can perform mutations against it.
getAndTouch()  : GetResult
Gets a document from the server and simultaneously updates its expiry time.
getAnyReplica()  : GetReplicaResult
Gets a document from any replica server in the cluster.
getMulti()  : array<string|int, mixed>
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.
insert()  : MutationResult
Inserts a document if it doesn't exist, errors if it does exist.
lookupIn()  : LookupInResult
Performs a set of subdocument lookup operations against the document.
mutateIn()  : MutateInResult
Performs a set of subdocument lookup operations against the document.
name()  : string
Get the name of the collection.
remove()  : MutationResult
Removes a document.
removeMulti()  : array<string|int, mixed>
Removes a group of documents. If second element of the entry (CAS) is null, then the operation will remove the document unconditionally.
replace()  : MutationResult
Replaces a document if it exists, errors if it doesn't exist.
touch()  : MutationResult
Touches a document, setting a new expiry time.
unlock()  : Result
Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.
upsert()  : MutationResult
Creates a document if it doesn't exist, otherwise updates it.
upsertMulti()  : array<string|int, mixed>
Creates a group of documents if they don't exist, otherwise updates them.

Methods

exists()

Checks if a document exists on the server.

public exists(string $id[, ExistsOptions $options = null ]) : ExistsResult
Parameters
$id : string

the key of the document to check if exists

$options : ExistsOptions = null

the options to use for the operation

Return values
ExistsResult

get()

Gets a document from the server.

public get(string $id[, GetOptions $options = null ]) : GetResult

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
$id : string

the key of the document to fetch

$options : GetOptions = null

the options to use for the operation

Return values
GetResult

getAllReplicas()

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

public getAllReplicas(string $id[, GetAllReplicasOptions $options = null ]) : array<string|int, mixed>

Returns an array of documents, one per server.

Parameters
$id : string

the key of the document

$options : GetAllReplicasOptions = null

the options to use for the operation

Return values
array<string|int, mixed>

getAndLock()

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

public getAndLock(string $id, int $lockTime[, GetAndLockOptions $options = null ]) : GetResult
Parameters
$id : string

the key of the document to get

$lockTime : int

the length of time to lock the document in ms

$options : GetAndLockOptions = null

the options to use for the operation

Return values
GetResult

getAndTouch()

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

public getAndTouch(string $id, int $expiry[, GetAndTouchOptions $options = null ]) : GetResult
Parameters
$id : string

the key of the document

$expiry : int

the length of time to update the expiry to in ms

$options : GetAndTouchOptions = null

the options to use for the operation

Return values
GetResult

getMulti()

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.

public getMulti(array<string|int, mixed> $ids[, GetOptions $options = null ]) : array<string|int, mixed>
Parameters
$ids : array<string|int, mixed>

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

$options : GetOptions = null

the options to use for the operation

Return values
array<string|int, mixed>

array of GetResult, one for each of the entries

insert()

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

public insert(string $id, mixed $value[, InsertOptions $options = null ]) : MutationResult
Parameters
$id : string

the key of the document

$value : mixed

the value to use for the document

$options : InsertOptions = null

the options to use for the operation

Return values
MutationResult

lookupIn()

Performs a set of subdocument lookup operations against the document.

public lookupIn(string $id, array<string|int, mixed> $specs[, LookupInOptions $options = null ]) : LookupInResult
Parameters
$id : string

the key of the document

$specs : array<string|int, mixed>

the LookupInSpecs to perform against the document

$options : LookupInOptions = null

the options to use for the operation

Return values
LookupInResult

mutateIn()

Performs a set of subdocument lookup operations against the document.

public mutateIn(string $id, array<string|int, mixed> $specs[, MutateInOptions $options = null ]) : MutateInResult
Parameters
$id : string

the key of the document

$specs : array<string|int, mixed>

the MutateInSpecs to perform against the document

$options : MutateInOptions = null

the options to use for the operation

Return values
MutateInResult

name()

Get the name of the collection.

public name() : string
Return values
string

removeMulti()

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

public removeMulti(array<string|int, mixed> $entries[, RemoveOptions $options = null ]) : array<string|int, mixed>
Parameters
$entries : array<string|int, mixed>

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

$options : RemoveOptions = null

the options to use for the operation

Return values
array<string|int, mixed>

array of MutationResult, one for each of the entries

replace()

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

public replace(string $id, mixed $value[, ReplaceOptions $options = null ]) : MutationResult
Parameters
$id : string

the key of the document

$value : mixed

the value to use for the document

$options : ReplaceOptions = null

the options to use for the operation

Return values
MutationResult

touch()

Touches a document, setting a new expiry time.

public touch(string $id, int $expiry[, TouchOptions $options = null ]) : MutationResult
Parameters
$id : string

the key of the document

$expiry : int

the expiry time for the document in ms

$options : TouchOptions = null

the options to use for the operation

Return values
MutationResult

unlock()

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

public unlock(string $id, string $cas[, UnlockOptions $options = null ]) : Result
Parameters
$id : string

the key of the document

$cas : string

the current cas value of the document

$options : UnlockOptions = null

the options to use for the operation

Return values
Result

upsert()

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

public upsert(string $id, mixed $value[, UpsertOptions $options = null ]) : MutationResult
Parameters
$id : string

the key of the document

$value : mixed

the value to use for the document

$options : UpsertOptions = null

the options to use for the operation

Return values
MutationResult

upsertMulti()

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

public upsertMulti(array<string|int, mixed> $entries[, UpsertOptions $options = null ]) : array<string|int, mixed>
Parameters
$entries : array<string|int, mixed>

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

$options : UpsertOptions = null

the options to use for the operation

Return values
array<string|int, mixed>

array of MutationResult, one for each of the entries

Search results