redis-cli "Error: Server closed the connection" when requesting lots of keys

redis-cli "Error: Server closed the connection" when requesting lots of keys

出于某种原因 运行 命令 KEYS 结果上有数百万个键的命令导致 Error: Server closed the connection

[nir]$ echo "keys abc" | redis-cli -h $redis
1) "abc"
[nir]$ echo "keys a*"| redis-cli -h $redis
Error: Server closed the connection

我猜是有超时限制什么的,我该如何调整?

解决方案是从 KEYS 移动到 redis-cli --scan --pattern <pattern>