Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// WARNING: right now, support for redis-cluster is experimental,
// unoptimized and in its very early stages of development. To
// play with it you must have a correct setup of redis-cluster
// running (oh hai mr. obvious) and Predis v0.7-dev fetched from
// the redis_cluster branch of the Git repository.
require 'autoload.php';
$servers = array(
'tcp://127.0.0.1:6379',
'tcp://127.0.0.1:6380',
'tcp://127.0.0.1:6381',
);
// Developers can specify which kind of cluster strategy the
// client should use with the recently added 'cluster' option
// and the following values:
// - predis : good old client-side sharding (default)
// - redis : redis-cluster
$client = new Predis\Client($servers, array('cluster' => 'redis'));
$client->set("foo", "bar");
$foo = $client->get("foo");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment