iankibet/redis-stream 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

iankibet/redis-stream

最新稳定版本:1.0.3

Composer 安装命令:

composer require iankibet/redis-stream

包简介

A Laravel package to listen to Redis published messages.

README 文档

README

Latest Stable Version Total Downloads License

A Laravel package to use Redis Streams for lightweight, scalable inter-service communication or job/event dispatching.

🚀 Features

  • Simple Redis Streams integration
  • Stream-to-handler mapping via config
  • Supports multiple consumers under the same group
  • Automatically dispatches Jobs or Events
  • Clean CLI command with optional consumer override

🛠 Installation

composer require iankibet/redis-stream

Publish the config:

php artisan vendor:publish --tag=redis-stream

⚙️ Configuration

Edit the generated config file at config/redis-stream.php:

return [
    'group' => env('REDIS_STREAM_GROUP', env('APP_NAME', 'laravel')),

    'consumer' => env('REDIS_STREAM_CONSUMER', env('REDIS_STREAM_GROUP', env('APP_NAME', 'laravel'))),

    'handlers' => [
        'user_activity' => [
            App\Jobs\ProcessUserActivity::class,
        ],
        'order_events' => [
            App\Events\OrderCreated::class,
        ],
    ],
];

📥 Publishing to a Stream

You can publish messages using the RedisStream facade:

use Iankibet\RedisStream\RedisStream;

RedisStream::publish('order_events', [
    'order_id' => 123,
    'status' => 'created',
]);

🧑‍💻 Consuming Messages

Run the consumer using:

php artisan redis:consume-stream

Or provide a specific consumer name:

php artisan redis:consume-stream worker-1

Messages are read from all streams defined in the config and dispatched automatically to jobs or events.

🧪 Testing

Run the tests:

php artisan test

🧠 Notes

  • Each message is delivered to only one consumer in a group.
  • Redis automatically tracks pending/unacknowledged messages.
  • You should monitor or use XPENDING and XCLAIM to handle stuck messages in production.

📄 License

MIT © Ian Kibet

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固