12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- require_once 'SharedConfigurations.php';
- $redis = new Predis\Client($single_server + array('read_write_timeout' => 0));
- $pubsub = $redis->pubSubContext();
- $pubsub->subscribe('control_channel');
- $pubsub->subscribe('notifications');
- foreach ($pubsub as $message) {
- switch ($message->kind) {
- case 'subscribe':
- echo "Subscribed to {$message->channel}\n";
- break;
- case 'message':
- if ($message->channel == 'control_channel') {
- if ($message->payload == 'quit_loop') {
- echo "Aborting pubsub loop...\n";
- $pubsub->unsubscribe();
- }
- else {
- echo "Received an unrecognized command: {$message->payload}.\n";
- }
- }
- else {
- echo "Received the following message from {$message->channel}:\n",
- " {$message->payload}\n\n";
- }
- break;
- }
- }
- unset($pubsub);
- $info = $redis->info();
- print_r("Goodbye from Redis v{$info['redis_version']}!\n");
- ?>
|