Redis SCAN命令返回不匹配模式的键

时间:2018-02-23 15:46:43

标签: redis

所以有任何想法为什么会这样?

localhost:0>scan 0 MATCH 20180223:c5*
 1)  "6553600"
 2)  
localhost:0>scan 6553600 MATCH 20180223:c5*
 1)  "655360"
 2)    1)   "20180223:c5192875:o4998561"
  2)   "20180223:c1354879:o1160565"
  3)   "20180223:c1008709:o814395"
  4)   "20180223:c4485666:o4291352"
  5)   "20180223:c4560776:o4366462"
  6)   "20180223:c1646865:o1452551"
  7)   "20180223:c3515588:o3321274"
  8)   "20180223:c938489:o744175"
  9)   "20180223:c4895806:o4701492"
  10)   "20180223:c1767235:o1572921"

localhost:0>

https://redis.io/commands/scan看起来这个扫描命令是对的,所以我不知道发生了什么。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

这不应该发生,我不能使用相同的密钥和debug populate 10000在本地(不稳定分支)重现它。

我正在使用下面的Lua脚本进行测试:

$ cat /tmp/lua
local cursor = 0
local rep = {}

repeat
  local r = redis.call('scan', cursor, 'match', '20180223:c5*')
  cursor = tonumber(r[1])
  for _, v in ipairs(r[2]) do
    table.insert(rep, v)
  end
until cursor == 0

return rep
$ redis-cli --eval /tmp/lua
1) "20180223:c5192875:o4998561"