我们使用Predis连接到AWS (Elasticache)上托管的Redis实例。我们正在经历性能问题,在尝试了其他与扩展相关的解决方案之后,我们希望尝试在集群中添加读副本(在集群模式下,没有切分,只需要读取副本)。Elasticache提供了这一特性,但是Predis的文档并不十分清楚如何使用不同的写/读端点。
我们目前以这种方式初始化RedisClient。
$redisClient = new RedisClient(['host' => 'the primary endpoint']);如何在构造函数中添加读取副本端点?
发布于 2022-07-05 19:09:43
PRedis的文档有点模糊(或过时)。如果有人面临同样的问题,我们就是这样做的:
$parameters = [
['host' => $primaryEndpoint, 'role' => 'master', 'alias' => 'master'],
['host' => $replicaEndpoint, 'role' => 'slave', 'alias' => 'slave'],
];
$this->redis = new RedisClient($parameters,
['replication' => true, 'throw_error' => true, 'async' => true]);role和alias属性非常重要。
根据PRedis文档,复制选项应该设置为'replication' => 'predis',但这不起作用。使用'replication' => true做了。
https://stackoverflow.com/questions/72776992
复制相似问题