Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: PHP 1.0
Community Wiki and Resources
Wiki: PHP Client Library
PHP Client Library
SDK Forum
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
Couchbase Client Library: PHP 1.0
Chapters

Chapter 8. Update Operations

Table 8.1. PHP Client Library Update Methods

MethodTitle
$object->append($key, $value [, $expiry ] [, $casunique ] [, $persistto ] [, $replicateto ]) Append a value to an existing key
$object->cas($casunique, $key, $value [, $expiry ]) Compare and set a value providing the supplied CAS key matches
$object->decrement($key, $offset) Decrement the value of an existing numeric key
$object->delete($key [, $casunique ]) Delete a key/value
$object->flush() Deletes all values from the corresponding bucket
$object->increment($key [, $offset ] [, $create ] [, $expiry ] [, $initial ]) Increment the value of an existing numeric key
$object->keyDurability($key, $casunique, $durability) Wait until the durability of a document has been reached
$object->keyDurabilityMulti($keycollection, $durability) Wait until the durability of a document has been reached
$object->observe($key, $casunique, $observedetails) Get the durability of a document
$object->observeMulti($keycollection, $observedetails) Get the durability of a document
$object->prepend($key, $value [, $expiry ] [, $casunique ] [, $persistto ] [, $replicateto ]) Prepend a value to an existing key
$object->touch($key, $expiry) Update the expiry time of an item
$object->touchMulti($keyarray, $expiry) Change the expiration time for multiple documents

API Call$object->append($key, $value [, $expiry ] [, $casunique ] [, $persistto ] [, $replicateto ])
Asynchronousno
Description Append a value to an existing key
Returnsscalar; supported values:
 COUCHBASE_E2BIGThe Object is too big to be stored on the server 
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 docidDocument ID on success 
Arguments 
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
$casunique Unique value used to verify a key/value combination
$persistto Specify the number of nodes on which the document must be persisted to before returning.
$replicateto Specify the number of nodes on which the document must be replicated to before returning
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->cas($casunique, $key, $value [, $expiry ])
Asynchronousno
Description Compare and set a value providing the supplied CAS key matches
Returnsboolean; supported values:
 COUCHBASE_E2BIGThe Object is too big to be stored on the server 
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_EEXISTSThe key exists, but the supplied CAS ID did not match the one for the object in the cluster 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 COUCHBASE_SUCCESSOperation succeeded 
Arguments 
$casunique Unique value used to verify a key/value combination
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->decrement($key, $offset)
Asynchronousno
Description Decrement the value of an existing numeric key. The Couchbase Server stores numbers as unsigned values. Therefore the lowest you can decrement is to zero.
Returnsscalar; supported values:
 COUCHBASE_DELTA_BADVALDecrement on an object that isn't a number 
 COUCHBASE_E2BIGThe Object is too big to be stored on the server 
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 scalarUpdated value of the object on success 
Arguments 
string $key Document ID used to identify the value
$offset Integer offset value to increment/decrement (default 1)
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->delete($key [, $casunique ])
Asynchronousno
Description Delete a key/value
Returnsscalar; supported values:
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 docidDocument ID of deleted document 
Arguments 
string $key Document ID used to identify the value
$casunique Unique value used to verify a key/value combination
API Call$object->increment($key [, $offset ] [, $create ] [, $expiry ] [, $initial ])
Asynchronousno
Description Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value.
Returnsscalar; supported values:
 COUCHBASE_DELTA_BADVALIncrement on an object that isn't a number 
 COUCHBASE_E2BIGThe Object is too big to be stored on the server 
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 scalarUpdated value of the object on success 
Arguments 
string $key Document ID used to identify the value
$offset Integer offset value to increment/decrement (default 1)
boolean $create Create the document if it does not already exist
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
boolean $initial Initial value for the document
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->prepend($key, $value [, $expiry ] [, $casunique ] [, $persistto ] [, $replicateto ])
Asynchronousno
Description Prepend a value to an existing key
Returnsscalar; supported values:
 COUCHBASE_E2BIGThe Object is too big to be stored on the server 
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 docidDocument ID on success 
Arguments 
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
$casunique Unique value used to verify a key/value combination
$persistto Specify the number of nodes on which the document must be persisted to before returning.
$replicateto Specify the number of nodes on which the document must be replicated to before returning
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->appendByKey($master_key, $key, $value [, $expiry ])
Asynchronousno
Description Append to a key on a specific server
Returnsscalar ( Binary object )
Arguments 
$master_key Master key used for consistent server references
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
API Call$object->prependByKey($master_key, $key, $value)
Asynchronousno
Description Prepend a value to a key on a specific server
Returnsscalar ( Binary object )
Arguments 
$master_key Master key used for consistent server references
string $key Document ID used to identify the value
object $value Value to be stored
API Call$object->replaceByKey($master_key, $key, $value [, $expiry ])
Asynchronousno
Description Replace a value on a specific server
Returnsscalar ( Binary object )
Arguments 
$master_key Master key used for consistent server references
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
API Call$object->deleteByKey($master_key, $key)
Asynchronousno
Description Delete a key/value on a specific server
Returnsscalar; supported values:
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 docidDocument ID of deleted document 
Arguments 
$master_key Master key used for consistent server references
string $key Document ID used to identify the value
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster
API Call$object->casByKey($casunique, $master_key, $key, $value [, $expiry ])
Asynchronousno
Description Compare and set a value providing the supplied CAS key matches
Returnsscalar ( Binary object )
Arguments 
$casunique Unique value used to verify a key/value combination
$master_key Master key used for consistent server references
string $key Document ID used to identify the value
object $value Value to be stored
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
API Call$object->touch($key, $expiry)
Asynchronousno
Description Update the expiry time of an item
Returnsboolean; supported values:
 COUCHBASE_ENOMEMOut of Resources 
 COUCHBASE_ETMPFAILTemporary failure; try the operation again 
 COUCHBASE_KEY_ENOENTRequested document ID does not exist 
 COUCHBASE_NOT_MY_VBUCKETThe command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation 
 COUCHBASE_NOT_STOREDThe object was not stored 
 COUCHBASE_SUCCESSOperation succeeded 
Arguments 
string $key Document ID used to identify the value
$expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
Errors 
CouchbaseAuthenticationException Authentication to the Couchbase cluster failed
CouchbaseException Base exception class for all Couchbase exceptions
CouchbaseIllegalKeyException The key provided is not a legal key identifier
CouchbaseLibcouchbaseException An error occurred within the libcouchbase library used by th PHP extension
CouchbaseServerException An error occurred within the Couchbase cluster