Skip to content

Instantly share code, notes, and snippets.

@wonjun27
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonjun27/665428b56d08991bc6ab to your computer and use it in GitHub Desktop.
Save wonjun27/665428b56d08991bc6ab to your computer and use it in GitHub Desktop.
<?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