yii2怎么使用redis官方集群cluster

技术问题 · codeloving · 于 5年前 发布 · 3926 次阅读

yii官方的redis扩展是不支持集群的,单机上使用是没有什么问题。 想咨询下 yii2使用redis的cluster的时候有什么比较好的实现

共收到 5 条回复
Fecmall#15年前 0 个赞

搜索了一下:

看到了帖子:https://github.com/yiisoft/yii2-redis/issues/66

里面有人搞了个扩展:https://github.com/pyurin/yii2-redis-ha

你看一下吧,不知道是否能用

Fecmall#35年前 0 个赞

官方的yii2-redis,好像只支持replicas 这种

https://github.com/yiisoft/yii2-redis/blob/ffe6bff8dc6be4bb84c9495cd3ef7ef1161c1314/src/Cache.php#L274:32

 [
 *     'components' => [
 *         'cache' => [
 *             'class' => 'yii\redis\Cache',
 *             'enableReplicas' => true,
 *             'replicas' => [
 *                 // config for replica redis connections, (default class will be yii\redis\Connection if not provided)
 *                 // you can optionally put in master as hostname as well, as all GET operation will use replicas
 *                 'redis',//id of Redis [[Connection]] Component
 *                 ['hostname' => 'redis-slave-002.xyz.0001.apse1.cache.amazonaws.com'],
 *                 ['hostname' => 'redis-slave-003.xyz.0001.apse1.cache.amazonaws.com'],
 *             ],
 *         ],
 *     ],
 * ]

没玩过这种,您研究一下,有收获后,分享一下。

codeloving#45年前 0 个赞

@Fecshop #3楼 上cluster肯定不只是用replicas,也需要sharding功能的,并且sharding功能是主要的。自己也找了一圈,目前打算直接用predis了

Fecmall#55年前 0 个赞

@codeloving #4楼 嗯,用6了,来做个分享哈。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics