gevman / yii2-redis-subscriber
Yii2 Redis Channel Subscriber implementation for yii2-redis
Installs: 260
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- yiisoft/yii2-redis: ^2.0
This package is auto-updated.
Last update: 2024-10-14 18:59:52 UTC
README
Yii2 Redis Channel Subscriber implementation for yii2-redis
installation
using composer
composer require gevman/yii2-redis-subscriber
- Configuration (pusher project)
'components' => [ //... 'redis' => [ 'class' => \yii\redis\Connection::class, 'hostname' => 'localhost', 'port' => 6379, ], //... ],
- Configuration (subscriber project)
'components' => [ //... 'redisSubscriber' => [ 'class' => \Gevman\Yii2RedisSubscriber\Connection::class, 'hostname' => 'localhost', 'port' => 6379, ], //... ],
Usage
- Push message to channel
\Yii::$app->redis->publish('some_channel', 'some message');
- Listen channel messages
\Yii::$app->redisSubscriber->listen( 'some_channel', function($type, $channel, $message) { do_something($type, $channel, $message); }, function(\Throwable $error) { \Yii::error($error->getMessage()); } );