2 class RedisPubSubFeedEngine
implements RCFeedEngine
{
4 * Emit a recent change notification via Redis Pub/Sub
6 * If the feed URI contains a path component, it will be used to generate a
7 * channel name by stripping the leading slash and replacing any remaining
8 * slashes with '.'. If no path component is present, the channel is set to
9 * 'rc'. If the URI contains a query string, its parameters will be parsed
10 * as RedisConnectionPool options.
12 * @example $wgRCFeeds['redis'] = array(
13 * 'formatter' => 'JSONRCFeedFormatter',
14 * 'uri' => "redis://127.0.0.1:6379/rc.$wgDBname",
19 public function send( array $feed, $line ) {
20 $parsed = parse_url( $feed['uri'] );
21 $server = $parsed['host'];
22 $options = array( 'serializer' => 'none' );
25 if ( isset( $parsed['port'] ) ) {
26 $server .= ":{$parsed['port']}";
28 if ( isset( $parsed['query'] ) ) {
29 parse_str( $parsed['query'], $options );
31 if ( isset( $parsed['pass'] ) ) {
32 $options['password'] = $parsed['pass'];
34 if ( isset( $parsed['path'] ) ) {
35 $channel = str_replace( '/', '.', ltrim( $parsed['path'], '/' ) );
37 $pool = RedisConnectionPool
::singleton( $options );
38 $conn = $pool->getConnection( $server );
39 $conn->publish( $channel, $line );