Predis\ClientException: Command ‘ZPOPMAX‘ is not a registered Redis command

问题

在使用predis包的时候,使用redis的ZPOPMAX命令,发现报错了,错误提醒如下:

Predis\ClientException: Command 'ZPOPMAX' is not a registered Redis command

背景

在PHP的日常开发中,在使用redis的时候 我们常用的redis包有两个,一个是predis/predis,另一个是phpredis/phpredis。

这两者的区别简单来说就是 phpredis/phpredis包是用c写的php的高效扩展,而predis是用php代码写的。

Laravel 官方原来是推荐使用 PRedis 的,因为纯 PHP 实现的原因,只需要 Composer 即可安装,非常符合 Laravel 便捷的思想。但现在由于 PRedis 这个插件好久都没有维护了,因此从 Laravel6 开始官方推荐推荐使用 phpredis 来代替 PRedis。

问题定位

经过对predis的源码进行调试,发现predis包里,predis/src/Profile/目录下存储了一系列的redisversion文件,里面记录了redis在对应版本及其以下版本中redis的命令,并且在通过predis包执行redis命令时,会对使用的redis命令进行校验,确认使用的命令是否在这个命令集合中存在,如果不存在则抛出上述异常。

在这里插入图片描述
并且,从上图可以看到,截止目前,predis支持的redis版本只支持到了redis3.2,也就是说3.2版本后新增的redis命令是无法通过predis包执行的,会被拦截。

使用phpredis代替predis

总结

如果有需求需要使用超过redis3.2过后的命令,如想使用predis包,建议先去github中确认一下predis包是否已经支持更高版本的redis命令,如果还不支持,建议选择新的redis包。

后续

2023-05-16 最近发现predis包在23年初已经重新开始继续维护,目前已经支持redis最新的一些特性和命令,大家可以根据自己的需求选择使用哪个包。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
As an AI language model, I cannot perform specific actions or access any server or network resources. However, I can provide some general information about the error message you shared. The error message "ClientException: Load balancer does not have available server for client: leadnews-wemedia" suggests that the load balancer is unable to find any available server to handle the client requests for the leadnews-wemedia service. A load balancer is responsible for distributing incoming traffic across multiple servers to ensure that no single server is overloaded and can efficiently handle the client's request. There could be several reasons why the load balancer is unable to find any available server, including: 1. The service is currently overloaded, and all servers are busy handling requests. 2. The servers associated with the load balancer are down or not responding. 3. The load balancer configuration is incorrect or outdated. To resolve this issue, you can try the following: 1. Check the server status associated with the load balancer and ensure they are running correctly. 2. Check the load balancer configuration to ensure it's set up correctly and updated. 3. Try increasing the number of servers associated with the load balancer to handle more traffic. 4. Contact your network administrator or your cloud provider's support team for further assistance. In summary, the "ClientException: Load balancer does not have available server for client: leadnews-wemedia" error message indicates that the load balancer is unable to find any available server for the leadnews-wemedia service. You can try troubleshooting the issue by checking the server status, load balancer configuration, and increasing the number of servers.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值