关于Horizon Redis无法支持集群的问题
关于在 laravel项目中horizon 无法使用的问题?
答复:这个问题可能永久性的不支持 Horizon 配置redis 集群队列
原因:
Horizon does not work with Redis Cluster and likely never will. Even if it did work with Clusters, you wouldn't be taking advantage of the clustering because Lua operations can't operate on multiple shards in one operation. And, for Horizon to work properly, our Lua scripts have to perform operations on multiple keys in one atomic transaction.
翻译过来:
Horizon 不适用于 Redis Cluster,而且可能永远不会。即使它确实适用于集群,您也不会利用集群,因为 Lua 操作无法在一个操作中对多个分片进行操作。而且,为了使 Horizon 正常工作,我们的 Lua 脚本必须在一个原子事务中对多个密钥执行操作。
这个不好的地方文档没有体现出来,查了一下文档,文档里面没有体现出来,不要相信网上那些帖子
下面这个代码可能永远都让你的代码走不到集群里面,哈哈
public static function use($connection)
{
if (! is_null($config = config("database.redis.clusters.{$connection}.0"))) {
config(["database.redis.{$connection}" => $config]);
} elseif (is_null($config) && is_null($config = config("database.redis.{$connection}"))) {
throw new Exception("Redis connection [{$connection}] has not been configured.");
}
$config['options']['prefix'] = config('horizon.prefix') ?: 'horizon:';
config(['database.redis.horizon' => $config]);
}
推断是 关于 队列pop的LUA原子性问题
:sweat_smile: 那我们在集群中用的 horizon 存在缺陷?不对吧,确认了 redis 分片就好了呀。
难道只能用:php artisan queue:work --queue={IndexDocUpdateJob} --timeout=60了吗? 现在解决这个问题了没啊?