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.
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.
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.

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

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

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

Search results