/** * Get all buckets. * @return array() of Bucket objects */ public function buckets() { $url = Utils::buildRestPath($this); $response = Utils::httpRequest('GET', $url . '?buckets=true'); $response_obj = json_decode($response[1]); $buckets = array(); foreach ($response_obj->buckets as $name) { $buckets[] = $this->bucket($name); } return $buckets; }
/** * Retrieve a sibling by sibling number. * @param integer $i - Sibling number. * @param integer $r - R-Value. Wait until this many partitions * have responded before returning to client. * @return Object. */ public function getSibling($i, $r = NULL) { # Use defaults if not specified. $r = $this->bucket->getR($r); # Run the request... $vtag = $this->siblings[$i]; $params = array('r' => $r, 'vtag' => $vtag); $url = Utils::buildRestPath($this->client, $this->bucket, $this->key, NULL, $params); $response = Utils::httpRequest('GET', $url); # Respond with a new object... $obj = new Object($this->client, $this->bucket, $this->key); $obj->jsonize = $this->jsonize; $obj->populate($response, array(200)); return $obj; }
/** * Retrieve an array of all keys in this bucket. * Note: this operation is pretty slow. * @return Array */ public function getKeys() { $params = array('props' => 'false', 'keys' => 'true'); $url = Utils::buildRestPath($this->client, $this, NULL, NULL, $params); $response = Utils::httpRequest('GET', $url); # Use a Object to interpret the response, we are just interested in the value. $obj = new Object($this->client, $this, NULL); $obj->populate($response, array(200)); if (!$obj->exists()) { throw \Exception("Error getting bucket properties."); } $keys = $obj->getData(); return array_map("urldecode", $keys["keys"]); }