crazydb/yii2-redis-cluster

yii2 with phpredis

1.2.1 2022-08-08 12:28 UTC

This package is auto-updated.

Last update: 2024-05-08 16:19:10 UTC


README

由于yiisoft/Yii2-redis 只支持单机redis,但近期的需求是在cluster模式下使用,所以简单包装一个轮子。

扩展仅支持cluster集群模式

依赖

  • PHP >= 5.6.0
  • Redis >= 3.0
  • ext-redis >= 3.0.0
  • Yii2 ~2.0.4

安装

composer require --prefer-dist crazydb/yii2-redis-cluster

配置

return [
    //....
    'components' => [
        'redisCluster' => [
            'class' => 'crazydb\redis\Connection',
            'hosts' => [
                'localhost:6379'
            ]
        ],
        'cache' => [
            'class' => 'crazydb\redis\Cache',
            'redisCluster' => [
                'hosts' => [
                    'localhost:6379'
                ]
            ]
        ],
        'session' => [
            'class' => 'crazydb\redis\Session',
            'redisCluster' => [
                'hosts' => [
                    'localhost:6379'
                ]
            ]
        ]
    ]
];

注意事项

  1. 未完全测试,请勿直接用于生产环境。
  2. 仅支持cluster集群模式。
  3. 仅支持cachesession组件,不支持ActiveRecord