yii官方的redis扩展是不支持集群的,单机上使用是没有什么问题。 想咨询下 yii2使用redis的cluster的时候有什么比较好的实现
搜索了一下:
看到了帖子:https://github.com/yiisoft/yii2-redis/issues/66
里面有人搞了个扩展:https://github.com/pyurin/yii2-redis-ha
你看一下吧,不知道是否能用
https://github.com/yiisoft/yii2-redis/issues/143
官方的yii2-redis,好像只支持replicas 这种
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'], * ], * ], * ], * ]
没玩过这种,您研究一下,有收获后,分享一下。
@Fecshop #3楼 上cluster肯定不只是用replicas,也需要sharding功能的,并且sharding功能是主要的。自己也找了一圈,目前打算直接用predis了
@codeloving #4楼 嗯,用6了,来做个分享哈。