hyperf / model-cache Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
报错信息:
PHP Warning: foreach() argument must be of type array|object, bool given in /data/php-server/vendor/hyperf/model-cache/src/Redis/HashGetMultiple.php on line 32
问题定位点:
// vendor/hyperf/model-cache/src/Redis/HashGetMultiple.php
public function parseResponse($data)
{
$result = [];
foreach ($data ?? [] as $item) {
if (! empty($item) && is_array($item)) {
$temp = [];
$count = count($item);
for ($i = 0; $i < $count; ++$i) {
$temp[$item[$i]] = $item[++$i];
}
$result[] = $temp;
}
}
return $result;
}
查看源码发现 $data 的值是通过lua脚本获取的,脚本内容:
// vendor/hyperf/model-cache/src/Redis/HashGetMultiple.php
public function getScript(): string
{
return <<<'LUA'
local values = {};
for i,v in ipairs(KEYS) do
if(redis.call('type',v).ok == 'hash') then
values[#values+1] = redis.call('hgetall',v);
end
end
return values;
LUA;
}
本地环境测试了一下,在没有任何缓存时、有部分缓存时、全部key均有缓存时都没有复现这个问题。。
目前服务是正常的(程序会当作空数组,即没有获取到缓存处理)
想问一下,什么情况下这个lua脚本会返回false呢??是不是redis配置有什么问题?
本地和线上的model-cache包版本均为 3.0.17
线上使用的docker镜像为 hyperf/hyperf:8.0-alpine-v3.16-swoole-v5.0.1
在我的本地环境下,当我使用findManyFromCache($ids)
的时候
$ids
大于400之后,同一个浏览器下两次请求进入控制器的时间产生了间隔。$ids
小于400的时候,同一个浏览器下没有两次请求进入控制器的时间产生了间隔
这种情况发生。limit()->get()
的时候,同一个浏览器下没有两次请求进入控制器的时间产生了间隔
这种情况发生。两次请求进入控制器的时间产生了间隔
这种情况发生。而且,这个间隔非常的相似,20s
所以,想请教一下,这个可能是我这里什么原因导致的?
分别尝试limit100、400、500、1000的情况下请求是否产生了间隔。
1.清除缓存,使用一个浏览器发送两个请求,limit限制100
2.清除缓存,使用一个浏览器发送两个请求,limit限制400
3.清除缓存,使用一个浏览器发送两个请求,limit限制500
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.