MediaWiki  REL1_22
RedisPubSubFeedEngine.php
Go to the documentation of this file.
00001 <?php
00002 class RedisPubSubFeedEngine implements RCFeedEngine {
00019     public function send( array $feed, $line ) {
00020         $parsed = parse_url( $feed['uri'] );
00021         $server = $parsed['host'];
00022         $options = array( 'serializer' => 'none' );
00023         $channel = 'rc';
00024 
00025         if ( isset( $parsed['port'] ) ) {
00026             $server .= ":{$parsed['port']}";
00027         }
00028         if ( isset( $parsed['query'] ) ) {
00029             parse_str( $parsed['query'], $options );
00030         }
00031         if ( isset( $parsed['pass'] ) ) {
00032             $options['password'] = $parsed['pass'];
00033         }
00034         if ( isset( $parsed['path'] ) ) {
00035             $channel = str_replace( '/', '.', ltrim( $parsed['path'], '/' ) );
00036         }
00037         $pool = RedisConnectionPool::singleton( $options );
00038         $conn = $pool->getConnection( $server );
00039         $conn->publish( $channel, $line );
00040     }
00041 }