12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- require __DIR__.'/shared.php';
- $sentinels = array(
- 'tcp://127.0.0.1:5380?timeout=0.100',
- 'tcp://127.0.0.1:5381?timeout=0.100',
- 'tcp://127.0.0.1:5382?timeout=0.100',
- );
- $client = new Predis\Client($sentinels, array(
- 'replication' => 'sentinel',
- 'service' => 'mymaster',
- ));
- $exists = $client->exists('foo') ? 'yes' : 'no';
- $current = $client->getConnection()->getCurrent()->getParameters();
- echo "Does 'foo' exist on {$current->role}? $exists.", PHP_EOL;
- $client->set('foo', 'bar');
- $current = $client->getConnection()->getCurrent()->getParameters();
- echo "Now 'foo' has been set to 'bar' on {$current->role}!", PHP_EOL;
- $bar = $client->get('foo');
- $current = $client->getConnection()->getCurrent()->getParameters();
- echo "We fetched 'foo' from {$current->role} and its value is '$bar'.", PHP_EOL;
|