相关疑难解决方法(0)

如何确定Redis中Lua脚本的执行时间?

我有一个小 Lua 脚本要在 Redis 中运行,我对获取执行时间感兴趣。

由于 Redis 的性质及其 Lua 实现,我无法在脚本的开始/返回点使用 TIME 函数,并将此信息包含在返回中进行处理(请参阅http://redis.io/commands/eval -作为纯函数的脚本)。这会导致错误:(error) ERR Error running script (call to f_a49ed2fea72f1f529843d6024d1515e76e69bcbd): Write commands not allowed after non deterministic commands

我已经搜索了可以执行的函数/调用,该函数/调用将返回上次运行脚本的执行时间,但尚未找到任何内容。

我正在使用 PHP 和 Predis 库。虽然我可以从 PHP 端检查执行时间,但我希望消除传输开销并找出 Lua 脚本将阻止对数据库的访问多长时间。如果我不需要更改 Redis 中存储的任何数据,我已经成功返回了时间,这些时间大约是 PHP 报告时间的 1/10。

如何确定 Redis 中 Lua 脚本的执行时间,而不是通过 PHP?

time lua execution redis

3
推荐指数
1
解决办法
4661
查看次数

标签 统计

execution ×1

lua ×1

redis ×1

time ×1