PHP Riak List Buckets

风格不统一 提交于 2019-12-13 02:57:51

问题


I am trying to use the Riak client for PHP and I cant find a way to get a list of all the buckets in the cluster. The docs on the Riak site say that it has support for it but i cant find any function that will do it.


回答1:


Here's how you list the buckets with the Riak PHP client:

<?php
require_once('riak-php-client/riak.php');
$client = new RiakClient('127.0.0.1', 8091);
$all_buckets = $client->buckets();
var_dump($all_buckets); // etc
?>



回答2:


The documentation does not provide all of the functions. I found the followinf function in the documentation.

  /**
* Get all buckets.
* @return array() of RiakBucket objects
*/
function buckets() {
$url = RiakUtils::buildRestPath($this);
$response = RiakUtils::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;

}



来源:https://stackoverflow.com/questions/12875126/php-riak-list-buckets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!