public function deleteAll($values) { if (is_array($values)) { foreach ($values as $val) { if (!empty($val)) { set_time_limit(30); $riak_key = new RiakObject($this->_riak, $this->_bucket, $val); if ($riak_key) { $riak_key->delete(); } } } $n = count($values); $this->_count += $n; if ($n && $this->_count) { echo sprintf("%d... ", $this->_count); } } }
/** * Get the RiakObject * * @param string $id Session ID * * @return RiakObject */ private function _session($id) { if (!$this->_session instanceof RiakObject) { $this->_session = $this->_bucket->get($id); // Create a new session if it doesn't exist if (!$this->_session->exists()) { $data = array('data' => '', 'atime' => time()); $this->_session = $this->_bucket->newObject($id, $data)->store(); } } return $this->_session; }
/* * ****************************************************************************** * ** NO CHANGES FROM HERE ON *** /******************************************************************************* */ $start_page = microtime(true); require_once "lib/riak-client.php"; // init the RIAK connection $riak = new RiakClient(HOST, HTTP_PORT); if (!$riak->isAlive()) { die("I couldn't ping the server. Check the HOST AND PORT settings..."); } // init the $bucket && $key if (isset($_GET['bucketName'])) { $bucket = new RiakBucket($riak, $_GET['bucketName']); $key = new RiakObject($riak, $bucket, $_GET['key']); } // delete a key if ($_GET['cmd'] == "deleteKey" && $_GET['bucketName'] && $_GET['key']) { $key->delete(); unset($_GET['key']); } // create a bucket with key=>value : "created"=>1 if ($_GET['cmd'] == 'createBucket') { if ($_POST['bucketName'] && $_POST['bucketName'] != 'Create a new bucket') { $data = array("created" => 1); $bucket = new RiakBucket($riak, $_POST['bucketName']); $x = $bucket->newObject("", $data); $x->store(); $buckets_json = $_COOKIE['buckets']; if (!empty($buckets_json)) {
/** * 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 RiakObject. */ 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 = RiakUtils::buildRestPath($this->client, $this->bucket, $this->key, NULL, $params); $response = RiakUtils::httpRequest('GET', $url); # Respond with a new object... $obj = new RiakObject($this->client, $this->bucket, $this->key); $obj->jsonize = $this->jsonize; $obj->populate($response, array(200)); return $obj; }