定制 lanfix/yii2-redis-pub-sub 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lanfix/yii2-redis-pub-sub

Composer 安装命令:

composer require lanfix/yii2-redis-pub-sub

包简介

Yii2 pub/sub component for Redis

README 文档

README

This library adds binding functions for Redis to publish and subscribe to channels.

How to install

You must do it for prepare system to work:

  • Compile php with php-redis extension if you use php-fpm or install php-redis apache module in other case.
  • Enable php-redis in php.ini extension=redis

Next install this library with composer

composer require --prefer-dist lanfix/yii2-redis-pub-sub

Or add this string to composer.json

"lanfix/yii2-redis-pub-sub": "*"

Set up

Firstly add to configure file web.php this code

'redisPubSub' => [
    'class' => 'lanfix\redis_pub_sub\RedisPubSub',
    'connect' => [
        'hostname' => 'localhost',
        'port' => 6379,
        'password' => ''
    ]
],

Usage

Subscribe to Redis channel

Warning! It function stops your application and wait messages!

It is desirable to run this function in parallel or in other daemon

Yii::$app->redisPubSub->subscribe('my-channel-name', function($message) {
    var_dump($message);
});

And sending message to this channel

Yii::$app->redisPubSub->publish('my-channel-name', 'Hello! How are you?');

To unsubscribe from channel use

Yii::$app->redisPubSub->unsubscribe('my-channel-name');

统计信息

  • 总下载量: 309
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固