farmani/laravel-openswoole-redis-pool

Laravel 包,提供 openswoole redis pool 集成,Laravel redis pool 缓存和会话驱动。旨在避免 redis 服务器超时异常

v1.0.0 2022-12-23 08:38 UTC

This package is auto-updated.

Last update: 2024-09-23 15:10:30 UTC


README

Laravel 包,提供 openswoole redis pool 集成,Laravel redis pool 缓存和会话驱动。

修改默认的 redis 数据库配置如下

'default' => [
    'url' => env('REDIS_URL'),
    'host' => env('REDIS_HOST', 'redis.waptap.dev'),
    'password' => env('REDIS_PASSWORD', null),
    'port' => env('REDIS_PORT', '6379'),
    'database' => env('REDIS_DB', '0'),
    'read_timeout' => 3.0,
    'timeout' => 15.0,
    'retry_interval' => 0,
    'reserved' => '',
    'pool' => [
        'min' => 128,
        'max' => 128,
        'idle_time' => -1,
        'idle_interval' => 1000,
        'heartbeat' => 3000,
        'retry_interval' => 10,
        'retry_times' => 3,
    ],
],

安装

composer require farmani/laravel-openswoole-redis-pool

如何使用

  • 步骤 1: 确保你有一个正确的 swoole 环境
  • 步骤 2: 在你的 config/cache.php 文件的 stores 部分添加以下新的存储配置,在 redis 数组下面
'redis_pool' => [
    'driver' => 'redis',
    'connection' => 'default',
],
  • 步骤 3: 在你的 .env 文件中将 redis 驱动或会话驱动改为 redis_pool,这样就完成了