PK
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"));
function extract_key_part($k) { return substr($k, 0, 3); // hash only on first 3 characters. } $ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("function" => "extract_key_part"));
// adding host3 to a ring containing host1 and host2. Read commands will look in the previous ring if the data is not found in the main ring. $ra = new RedisArray(array("host1", "host2", "host3"), array("previous" => array("host1", "host2")));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("retry_interval" => 100));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("lazy_connect" => true));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("connect_timeout" => 0.5));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("read_timeout" => 0.5));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("algorithm" => "md5"));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("consistent" => true));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("auth" => "mysecretpassword"));
// list available Redis Arrays ini_set('redis.array.names', 'users,friends'); // set host names for each array. ini_set('redis.arrays.hosts', 'users[]=localhost:6379&users[]=localhost:6380&users[]=localhost:6381&users[]=localhost:6382&friends[]=localhost'); // set functions ini_set('redis.arrays.functions', 'users=user_hash'); // use index only for users ini_set('redis.arrays.index', 'users=1,friends=0'); // use password for authentication ini_set('redis.arrays.auth', 'users=mysecretpassword')
$ra = new RedisArray("users"); $ra->set("user1:name", "Joe"); $ra->set("user2:name", "Mike");
$ra = new RedisArray(array("host1", "host2", "host3", "host4", "host5", "host6", "host7", "host8"), array("distributor" => array(2, 2)));
$ra = new RedisArray("users"); // load up a new config from redis.ini, using the “.previous” listing. $ra->_rehash();
$host = $ra->_target("{users}:user1:name"); // find host first $ra->multi($host) // then run transaction on that host. ->del("{users}:user1:name") ->srem("{users}:index", "user1") ->exec();
$ cd tests $ ./mkring.sh start $ php array-tests.php