
第一次请求的时候,hGetAll返回的count_comment是58,然后hincrBy +1后再hGetAll,返回的count_comment预期为59却变成1了。没有实现预期递增效果。

再次执行同样请求,hGetAll返回的count_comment是1,然后hincrBy +1后再hGetAll,返回的count_comment是2了。这次请求hincrBy +1是实现的预期递增。

不太清楚是什么情况造成,找了好久没找到原因。
这里的redis中使用phpredis来连接count_comment都是string类型。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我找到问题了
This is expected, you can't run INCR, INCRBY, or HINCRBY on
serializeddata.初始化redis时,使用的是
SERIALIZER格式下存储