示例#1
0
 /**
  * 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;
 }
示例#2
0
}
// 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)) {
            $buckets_array = json_decode($buckets_json, true);
            if (is_array($buckets_array)) {
                $buckets_array[] = $_POST['bucketName'];
            }
            $buckets = json_encode($buckets_array);
            setcookie('buckets', $buckets);
            $page = $_SERVER['PHP_SELF'];
            header("Refresh: 0; url={$page}/../");
        }
    } else {
        ?>