Bucket
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:
|
|
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:
|
|
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
Returns the name of the bucket for current connection
Returns an instance of a CouchbaseBucketManager for performing management operations against a bucket.
Sets custom encoder and decoder functions for handling serialization.
Retrieves a document and locks it.
Retrieves a document and updates its expiration time.
Retrieves a document from a replica.
Inserts or updates a document, depending on whether the document already exists on the cluster.
Inserts a document. This operation will fail if the document already exists on the cluster.
Replaces a document. This operation will fail if the document does not exists on the cluster.
Appends content to a document.
Prepends content to a document.
Updates document's expiration time.
Increments or decrements a key (based on $delta)
Returns a builder for reading subdocument API.
Retrieves specified paths in JSON document
Returns a builder for writing subdocument API.
Performs a query to Couchbase Server
Returns size of the map
Add key to the map
Removes key from the map
Get an item from a map
Returns size of the set
Add value to the set
Check if the value exists in the set
Remove value from the set
Returns size of the list
Add an element to the end of the list
Add an element to the beginning of the list
Remove an element at the given position
Get an element at the given position
Set an element at the given position
Check if the list contains specified value
Returns size of the queue
Checks if the queue contains specified value
Add an element to the beginning of the queue
Remove the element at the end of the queue and return it
Try to reach specified services, and measure network latency.
Collect and return information about state of internal network connections.
Encrypt fields inside specified document.
Decrypt fields inside specified document.
Details
string
getName()
Returns the name of the bucket for current connection
BucketManager
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.
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.
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.
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.
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.
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)
LookupInBuilder
lookupIn(string $id)
Returns a builder for reading subdocument API.
DocumentFragment
retrieveIn(string $id, string ...$paths)
Retrieves specified paths in JSON document
This is essentially a shortcut for lookupIn($id)->get($paths)->execute()
.
MutateInBuilder
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
Note, that currently only primitive values could be stored in the set (strings, integers and booleans).
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.