123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- require 'SharedConfigurations.php';
- $redis = new Predis\Client($single_server + array('read_write_timeout' => 0));
- $pubsub = $redis->pubSubContext();
- $pubsub->subscribe('control_channel', '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");
|