Examples: bulk update.

This commit is contained in:
Daniele Alessandri
2010-05-22 14:48:37 +02:00
parent d585b11bf5
commit dad3704488
6 changed files with 29 additions and 19 deletions
+3 -8
View File
@@ -1,5 +1,5 @@
<?php
require '../lib/Predis.php';
require_once 'SharedConfigurations.php';
// Developers can customize the distribution strategy used by the client
// to distribute keys among a cluster of servers simply by creating a class
@@ -40,16 +40,11 @@ class NaiveDistributionStrategy
}
}
$servers = array(
'redis://127.0.0.1:6379?alias=first',
'redis://127.0.0.1:6380?alias=second',
);
$options = array(
'key_distribution' => new NaiveDistributionStrategy(),
);
$redis = new Predis\Client($servers, $options);
$redis = new Predis\Client($multiple_servers, $options);
for ($i = 0; $i < 100; $i++) {
$redis->set("key:$i", str_pad($i, 4, '0', 0));
@@ -60,6 +55,6 @@ $server1 = $redis->getClientFor('first')->info();
$server2 = $redis->getClientFor('second')->info();
printf("Server '%s' has %d keys while server '%s' has %d keys.\n",
'first', $server1['db0']['keys'], 'second', $server2['db0']['keys']
'first', $server1['db15']['keys'], 'second', $server2['db15']['keys']
);
?>