$hash = $this->hash($value);
        $node = $this->getByHash($hash);
        return $node;
    }
    public function hash($value)
    {
        return crc32($value);
    }
    public function getHashGenerator()
    {
        return $this;
    }
}
$options = array('cluster' => function () {
    $distributor = new NaiveDistributor();
    $strategy = new PredisStrategy($distributor);
    $cluster = new PredisCluster($strategy);
    return $cluster;
});
$client = new Predis\Client($multiple_servers, $options);
for ($i = 0; $i < 100; $i++) {
    $client->set("key:{$i}", str_pad($i, 4, '0', 0));
    $client->get("key:{$i}");
}
$server1 = $client->getClientFor('first')->info();
$server2 = $client->getClientFor('second')->info();
if (isset($server1['Keyspace'], $server2['Keyspace'])) {
    $server1 = $server1['Keyspace'];
    $server2 = $server2['Keyspace'];
}
printf("Server '%s' has %d keys while server '%s' has %d keys.\n", 'first', $server1['db15']['keys'], 'second', $server2['db15']['keys']);
示例#2
0
    $_SESSION['server_alias'] = $_REQUEST["db-alias"];
} else {
    if (!isset($_SESSION['server_alias'])) {
        $_SESSION['server_alias'] = $CONFIG_HOST[0]['alias'];
    }
}
if (isset($_REQUEST["db"])) {
    $_SESSION['db_num'] = $_REQUEST["db"];
} else {
    if (!isset($_SESSION['db_num'])) {
        $_SESSION['db_num'] = 0;
    }
}
$client = new Predis\Client($CONFIG_HOST);
global $redis;
$redis = $client->getClientFor($_SESSION['server_alias']);
$is_demo = false;
$script_name = '/admin/maintenace/redis';
//isset( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['SCRIPT_NAME'] : "rb.php";
/***************************************************************************
 * 
 * parse parameters for action, sort and pattern
 *  
 */
$action = "b";
if (isset($_REQUEST['a'])) {
    $action = $_REQUEST['a'];
}
$sort = "no";
if (isset($_REQUEST["s"])) {
    if ($_REQUEST["s"] !== "ttl" && $_REQUEST["s"] !== "key" && $_REQUEST["s"] !== "sz" && $_REQUEST["s"] !== "1" && $_REQUEST["s"] !== "no") {