only succeed if the * identifier exists in the cluster with the exact same cas value * as the one specified in this request. * * @param string $id the identifier to store the document under * @param object|string $document the document to store * @param integer $expiry the lifetime of the document (0 == infinite) * @param string $cas a cas identifier to restrict the store operation * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return string the cas value of the object if success * @throws CouchbaseException if an error occurs */ function set($id, $document, $expiry = 0, $cas = "", $persist_to = 0, $replicate_to = 0) { } /** * Store multiple documents in the cluster. * * @param array $documents an array containing "id" => "document" pairs * @param integer $expiry the lifetime of the document (0 == infinite) * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return boolean true if success * @throws CouchbaseException if an error occurs */ function setMulti($documents, $expiry = 0, $persist_to = 0, $replicate_to = 0) { } /** * Replace a document in the cluster. * * The replace operation replaces an existing document in the cluster. * It differs from add and set in the way that it requires the precense of * the identifier in the cluster. * * If the $cas field is specified set will only succeed if the * identifier exists in the cluster with the exact same cas value * as the one specified in this request. * * @param string $id the identifier to store the document under * @param object $document the document to store * @param integer $expiry the lifetime of the document (0 == infinite) * @param string $cas a cas identifier to restrict the replace operation * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return string the cas value of the object if success * @throws CouchbaseException if an error occurs */ function replace($id, $document, $expiry = 0, $cas = "", $persist_to = 0, $replicate_to = 0) { } /** * Prepend a document to another document. * * The prepend operation prepends the attached document to the document * already stored in the cluster. * * If the $cas field is specified prepend will only succeed if the * identifier exists in the cluster with the exact same cas value * as the one specified in this request. * * @param string $id identifies the document * @param object $document the document to prepend * @param integer $expiry the lifetime of the document (0 == infinite) * @param string $cas a cas identifier to restrict the prepend operation * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return string the cas value of the object if success * @throws CouchbaseException if an error occurs */ function prepend($id, $document, $expiry = 0, $cas = "", $persist_to = 0, $replicate_to = 0) { } /** * Append a document to another document. * * The append operation appends the attached document to the document * already stored in the cluster. * * If the $cas field is specified append will only succeed if the * identifier exists in the cluster with the exact same cas value * as the one specified in this request. * * @param string $id identifies the document * @param object $document the document to append * @param integer $expiry the lifetime of the document (0 == infinite) * @param string $cas a cas identifier to restrict the append operation * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return string the cas value of the object if success * @throws CouchbaseException if an error occurs */ function append($id, $document, $expiry = 0, $cas = "", $persist_to = 0, $replicate_to = 0) { } /** * Please use replace with the $cas field specified. */ function cas($cas, $id, $document, $expiry) { } /** * Retrieve a document from the cluster. * * @param string $id identifies the object to retrieve * @param callable $callback a callback function to call for missing * objects. The function signature looks like: * bool function($res, $id, &$val) * if the function returns true the value * returned through $val is returned. Please note that * the cas field is not updated in these cases. * @param string $cas where to store the cas identifier of the object * @return object The document from the cluster * @throws CouchbaseException if an error occurs */ function get($id, $callback = NULL, &$cas = "") { } /** * Retrieve multiple documents from the cluster. * * @param array $ids an array containing all of the document identifiers * @param array $cas an array to store the cas identifiers of the documents * @param int $flags may be 0 or COUCHBASE_GET_PRESERVE_ORDER * @return array an array containing the documents * @throws CouchbaseException if an error occurs */ function getMulti($ids, &$cas = array(), $flags = 0) { } /** * Retrieve a replica of a document from the cluster. * * Please note that this method is currently experimental and its * signature may change in a future release. * * @param string $id identifies the object to retrieve * @param callable $callback a callback function to call for missing * objects. The function signature looks like: * bool function($res, $id, &$val) * if the function returns true the value * returned through $val is returned. Please note that * the cas field is not updated in these cases. * @param string $cas where to store the cas identifier of the object * @return object The document from the cluster * @throws CouchbaseException if an error occurs */ function getReplica($id, $callback = NULL, &$cas = "") { } /** * Retrieve multiple replica documents from the cluster. * * Please note that this method is currently experimental and its * signature may change in a future release. * * @param array $ids an array containing all of the document identifiers * @param array $cas an array to store the cas identifiers of the documents * @return array an array containing the documents * @throws CouchbaseException if an error occurs */ function getReplicaMulti($ids, &$cas = array()) { } /** * Retrieve an object from the cache and lock it from modifications. * * While the object is locked it may only be modified by providing the * cas field returned in the cas field. Modifying the object automatically * unlocks the object. To manually unlock the object use the unlock() * method. All locks is automatically released after a configurable (on the * cluster) time interaval. * * @param string $id identifies the document * @param string $cas where to store the cas identifier * @param integer $expiry a configuratble lock expiry time (0 == use the * value configured on the server). * @return object The requested document from the cluster * @throws CouchbaseException if an error occurs */ function getAndLock($id, &$cas = "", $expiry = 0) { } /** * Retrieve and lock multiple documents from the cache. * * While the object is locked it may only be modified by providing the * cas field returned in the cas field. Modifying the object automatically * unlocks the object. To manually unlock the object use the unlock() * method. All locks is automatically released after a configurable (on the * cluster) time interaval. * * Bear in mind that locking multiple objects at the same time may not be * a good idea and may lead to deadlock ;-) * * @param array $ids an array containing the identifiers to retrieve * @param array $cas where to store the cas identifier * @param int $flags TODO update document for this param * @param integer $expiry a configuratble lock expiry time (0 == use the * value configured on the server). * @return array an array containint the requested documents * @throws CouchbaseException if an error occurs */ function getAndLockMulti($ids, &$cas = array(), $flags = 0, $expiry = 0) { } /** * Retrieve a document from the cluster and update its time to live. * * @param string $id identifies the document * @param integer $expiry the new time to live (0 == infinite) * @param string $cas where to store the cas identifier * @return object The requested document from the cluster * @throws CouchbaseException if an error occurs */ function getAndTouch($id, $expiry = 0, &$cas = "") { } /** * Retrieve multiple documents from the cluster and update their time to live. * * @param array $ids an array containint the document identifiers * @param integer $expiry the new time to live (0 == infinite) * @param array $cas where to store the cas identifier * @return array an array containing the requested documents * @throws CouchbaseException if an error occurs */ function getAndTouchMulti($ids, $expiry = 0, &$cas = array()) { } /** * Unlock a previously locked document. * * @param string $id the document to unlock * @param string $cas the cas value obtained from getAndLock() * @return boolean true upon success * @throws CouchbaseException if an error occurs */ function unlock($id, $cas) { } /** * Touch (update time to live) a document in the cluster. * * @param string $id identifies the document * @param integer $expiry the new time to live (0 == infinite) * @return boolean true upon success * @throws CouchbaseException if an error occurs */ function touch($id, $expiry) { } /** * Touch (update time to live) multiple documents in the cluster. * * @param array $ids an array containing the document identifiers * @param integer $expiry the new time to live (0 == infinite) * @return boolean true upon success * @throws CouchbaseException if an error occurs */ function touchMulti($ids, $expiry) { } /** * Delete a document from the cluster. * * @param string $id the document identifier * @param string $cas a cas identifier to restrict the store operation * @param integer $persist_to wait until the document is persisted to (at least) * this many nodes * @param integer $replicate_to wait until the document is replicated to (at least) * this many nodes * @return string the cas value representing the delete document if success * @throws CouchbaseException if an error occurs */ function delete($id, $cas = "", $persist_to = 0, $replicate_to = 0) { } /** * Increment a numeric value in the cluster. * * If the value isn't created by using increment / decrement, it has to * be created as a "textual" string like: * $cb->add("mycounter", "0");. The reason for this is * that the operation is performed in the cluster and it has to know * the datatype in order to perform the operation. * * @param string $id the document identifier * @param integer $delta the amount to increment * @param boolean $create should the value be created if it doesn't exist * @param integer $expire the time to live for the document (0 == infinite) * @param integer $initial the initial value for the counter if it doesn't exist * @return integer the new value upon success * @throws CouchbaseException if an error occurs */ function increment($id, $delta = 1, $create = false, $expire = 0, $initial = 0) { } /** * Decrement a numeric value in the cluster. * * If the value isn't created by using increment / decrement, it has to * be created as a "textual" string like: * $cb->add("mycounter", "0");. The reason for this is * that the operation is performed in the cluster and it has to know * the datatype in order to perform the operation. * * @param string $id the document identifier * @param integer $delta the amount to decrement * @param boolean $create should the value be created if it doesn't exist * @param integer $expire the time to live for the document (0 == infinite) * @param integer $initial the initial value for the counter if it doesn't exist * @return integer the new value upon success * @throws CouchbaseException if an error occurs */ function decrement($id, $delta = 1, $create = false, $expire = 0, $initial = 0) { } /** * Delete all documents in the bucket. * * Please note that flush is disabled from the server by default, so it * must explicitly be enabled on the bucket. Flush also require the object * to be used to contain all the credentials (username, password and * bucket name). * * @return boolean true upon success * @throws CouchbaseException if an error occurs */ function flush() { } /** * Issue a get request, but do not wait for responses. * * @param array $ids the document identifiers to retrieve * @param boolean $with_cas if the cas identifier should be retrieved * @param callable $callback function to call per retrieved document * @param integer $expiry lock expiry time * @param boolean $lock if the documents should be locked or not * @return boolean true upon success, false otherwise * @throws CouchbaseException if an error occurs */ function getDelayed($ids, $with_cas = false, $callback = null, $expiry = 0, $lock = false) { } /** * Fetch the one of the received documents requested from getDelayed. * * @return array an array representing the next document retrieved, * or NULL if there are no more documents. * @throws CouchbaseException if an error occurs */ function fetch() { } /** * Fetch the one of the received documents requested from getDelayed. * * @return array an array representing the documents retrieved, * or NULL if there are no more documents. * @throws CouchbaseException if an error occurs */ function fetchAll() { } /** * Execute a view request. * * The following options are recognized. * * * * * * * * * * * * * * * * * * * * *
NameDatatype
descendingboolean
endkeyJSON value
endkey_docidstring
full_setboolean
groupboolean
group_levelnumeric
inclusive_endboolean
keyJSON
keysJSON array
on_errorcontinue or stop
reduceboolean
staleboolean
skipnumeric
limitnumeric
startkeyJSON
startkey_docidstring
debugboolean
connection_timeoutnumeric
* * @todo update the table above with a description. * @param string $document The design document containing the view to call * @param string $view The view to execute * @param array $options extra options to add to the view request (see above) * @param boolean $return_errors Should error messages be returned upon failures * @return array an array with the result of the view request upon success, * or an array containing an error message * @throws CouchbaseException if an error occurs */ function view($document, $view = "", $options = array(), $return_errors = false) { } /** * Generate a view request. * * @param string $document The design document containing the view to call * @param string $view The view to execute * @param array $options extra options to add to the view request (see view() * for more information) * @param boolean $return_errors Should error messages be returned upon failures * @return string generated view request in format: "/_design/$doc/_view/$view?stale=ok&..." * @throws CouchbaseException if an error occurs */ function viewGenQuery($document, $view = "", $options = array(), $return_errors = false) { } /** * Retrieve statistics information from the cluster. * * @return array an array containing all "key" => "value" pairs upon success * @throws CouchbaseException if an error occurs */ function getStats() { } /** * Get the last result code from the extension internals. * * @return integer An error code representing the last error code as * seen by libcouchbase */ function getResultCode() { } /** * Get a textual representation of the last result from the extension * internals. * * @return string An textual string describing last error code as * seen by libcouchbase */ function getResultMessage() { } /** * Update one of the tunables. * * The following tunables exist: * * * * * * *
NameDescription
COUCHBASE_OPT_SERIALIZERSpecifies the serializer to * use to store objects in the cluster. The following values may be used: * COUCHBASE_SERIALIZER_PHP, COUCHBASE_SERIALIZER_JSON, * COUCHBASE_SERIALIZER_JSON_ARRAY
COUCHBASE_OPT_COMPRESSIONSpecifies the compression to * use for big objects. It may be set to the following values: * COUCHBASE_COMPRESSION_NONE, COUCHBASE_COMPRESSION_FASTLZ, * COUCHBASE_COMPRESSION_ZLIB
COUCHBASE_OPT_PREFIX_KEYA text string used as a prefix * for all keys (may be used to create your own namespace).
COUCHBASE_OPT_IGNOREFLAGSThis options is used to disable * the deserialisation of the data received from the cluster. It is mainly * used by the developers of the extension to be able to test variable * parts of the API and should not be used by end users (it may be removed * without notice if we find a better way to do this).
* * @param integer $option the option to set * @param integer $value the new value for the option * @throws CouchbaseException if an error occurs (e.g illegal option / value) */ function setOption($option, $value) { } /** * Retrieve the current value of a tunable. * * @param integer $option the option to retrieve the value for * @return integer The current value for a tunable. See setOption() for a * description of the legal options to retrieve. * @throws CouchbaseException if an error occurs (e.g illegal option) */ function getOption($option) { } /** * Get the version numbers of the memcached servers in the cluster. * * This method does probably not do what you think it would do. It * exists for compatibility with the "memcached" extension. It does * not return the Couchbase version used on each node in the * cluster, but rather an internal version number from the memcached * nodes in the cluster. * * The easiest way to get the Couchbase version nodes would be * something among the lines of: * *
     * $cb = new CouchbaseClusterManager("localhost", "Administrator", "secret");
     * $info = json_decode($cb->getInfo());
     * foreach ($info->{"nodes"} as $node) {
     *    print $node->{"hostname"} . " is running " . $node->{"version"} . "\n";
     * }
     * 
* @return array an array containing the memcached version on each node * @throws CouchbaseException if an error occurs */ function getVersion() { } /** * Retrieve the version number of the client. * * @return string client library version number */ function getClientVersion() { } /** * Get the number of replicas configured for the bucket. * * Note that even if the bucket is configured to use this number of * replicas doesn't necessarily mean that this number of replicas exist. * It is possible to set the number of replicas higher than the number * of nodes. * * @return integer The number of replicas for the bucket * @throws CouchbaseException if an error occurs */ function getNumReplicas() { } /** * Get the name of the servers in the cluster. * * @return array an array containing all of the servers in the cluster * @throws CouchbaseException if an error occurs */ function getServers() { } /** * Get information about a key in the cluster. * * @param string $id The identifier to get information about * @param string $cas The cas for the document to get information about * @param array $details an array to store the details about the key * @todo update the documentation about the name and meaning of the details * @return bool true on success, false otherwise * @throws CouchbaseException if an error occurs */ function observe($id, $cas, &$details = array()) { } /** * Get information about multiple keys in the cluster. * * @param array $ids an array containing the identifiers to look up * @param array $details an array to store the details about the documents * @return array with the keys with true on success, false otherwise * @throws CouchbaseException if an error occurs */ function observeMulti($ids, &$details = array()) { } /** * Wait for a document to reach a certain state. * * * * * * * * *
NameDescription
persist_toThe number of nodes the document should be * persisted to
replicate_toThe number of nodes the document should be * replicated to
timeoutThe max time to wait for durability
intervalThe interval between checking the state of * the document
* * @param string $id the identifier for the document to wait for * @param string $cas the cas identifier for the document to wait for * @param array $details an array containing the details. see above * @return bool true on success, false otherwise * @throws CouchbaseException if an error occurs */ function keyDurability($id, $cas, $details = array()) { } /** * Wait for multiple documents to reach a certain state. * * @param array $ids an array containing "identifier" => "cas" pairs * @param array $details is an array containing the options to wait for. * See keyDurability() for a description. * @return array with the keys with true on success, false otherwise * @throws CouchbaseException if an error occurs */ function keyDurabilityMulti($ids, $details = array()) { } /** * Retrieve the current operation timeout. * * @return integer The currently used timeout specified in usec */ function getTimeout() { } /** * Specify an operation timeout. * * The operation timeout is the time it takes from the command is sent * to the cluster and the result should be returned back. * * @param integer $timeout the new operation timeout specified in usec */ function setTimeout($timeout) { } /** * Get a design document from the cluster. * * @param string $name The design document to retrieve * @return string the content of the document if success * @throws CouchbaseException if an error occurs */ function getDesignDoc($name) { } /** * Store a design document in the cluster. * * Please note that this method will overwrite any existing design document * with the same name. * * @param string $name the name of the design document to store * @param string $document the new document to create * @return bool true on success * @throws CouchbaseException if an error occurs */ function setDesignDoc($name, $document) { } /** * Delete the named design document from the cluster. * * @param string $name the name of the design document to delete * @return bool true on success * @throws CouchbaseException if an error occurs */ function deleteDesignDoc($name) { } /** * List all design documents for this bucket * * @return string A JSON encoded string containing all information about * the design documents * @throws CouchbaseException if an error occurs */ function listDesignDocs() { } } class CouchbaseClusterManager { /** * Create a new instance of the CouchbaseClusterManager. * * @param array $hosts This is an array of hostnames[:port] where the * Couchbase cluster is running. The port number is * optional (and only needed if you're using a non- * standard port). * @param string $user This is the username used for authentications towards * the cluster * @param string $password This is the password used to authenticate towards * the cluster */ function __construct($hosts, $user, $password) { } /** * Get information about the cluster. * * @return string a JSON encoded string containing information of the * cluster. */ function getInfo() { } /** * Get information about one (or more) buckets. * * @param string $name if specified this is the name of the bucket to get * information about * @return string A JSON encoded string containing all information about * the requested bucket(s). */ function getBucketInfo($name = "") { } /** * Create a new bucket in the cluster with a given set of attributes. * * The bucket may be created with the following attributes: * * * * * * * * * * * *
PropertyDescription
typeThe type of bucket to create. This may be * memcached or couchbase
authThe type of authentication to use to access the * bucket. This may be sasl or none. If * none is used you must specicy a port * attribute. for sasl you may specify a * password attribute
enable flushIf flush() should be allowed * on the bucket
parallel compactionIf compaction of the database files * should be performed in parallel or not (only * applicable for couchbase buckets)
portIf the auth attribute is set to * none this attribute specifies the port number where * clients may access the bucket.
quotaThis specifies the amount of memory in MB the bucket * should consume on each node in the cluster
index replicasIf replicas should be indexed or not (only * applicable for couchbase buckets)
replicasThe number of replicas to create per document. * The current version of Couchbase supports the following values: 0, 1, 2 and 3 (only * applicable for couchbase buckets)
passwordThis is the password used to access the bucket if * the auth attribute is set to sasl
* * @param string $name the name of the bucket to create * @param array $attributes a hashtable specifying the attributes for the * bucket to create. */ function createBucket($name, $attributes) { } /** * Modify the attributes for a given bucket. * * Please note that you have to specify all attributes for the * bucket, so if you want to change a single attribute you should get * the current attributes, change the one you want and store the updated * attribute set. * * For a description of the different attribytes, see createBucket() * * @param string $name the name of the bucket to modify * @param array $attributes a hashtable specifying the new attributes for * the bucket */ function modifyBucket($name, $attributes) { } /** * Delete the named bucket. * * @param string $name the bucket to delete */ function deleteBucket($name) { } /** * Flush (delete the content) the named bucket. * * @param string $name the bucket to flush */ function flushBucket($name) { } } //////////////////////////////////////////////////////// // // // The following exception classes exists // // // //////////////////////////////////////////////////////// class CouchbaseException extends Exception { } class CouchbaseIllegalKeyException extends CouchbaseException { } class CouchbaseNoSuchKeyException extends CouchbaseException { } class CouchbaseAuthenticationException extends CouchbaseException { } class CouchbaseLibcouchbaseException extends CouchbaseException { } class CouchbaseServerException extends CouchbaseException { } class CouchbaseKeyMutatedException extends CouchbaseException { } class CouchbaseTimeoutException extends CouchbaseException { } class CouchbaseNotEnoughNodesException extends CouchbaseException { } class CouchbaseIllegalOptionException extends CouchbaseException { } class CouchbaseIllegalValueException extends CouchbaseException { }