命令
使用以下命令启动完整哈希扫描
HSCAN myhash 0
使用与模式匹配的字段开始哈希扫描:
HSCAN myhash 0 MATCH order_ *
使用与模式匹配的字段启动哈希扫描,并强制扫描命令执行更多扫描:
HSCAN myhash 0 MATCH order_ * COUNT 1000
注意
不要忘记MATCH每次迭代都可以返回很少甚至没有元素,如documentation中所述:
It is important to note that the MATCH filter is applied after
elements are retrieved from the collection, just before returning data
to the client. This means that if the pattern matches very little
elements inside the collection, SCAN will likely return no elements in
most iterations.
这就是为什么你可以使用COUNT强制每次迭代进行更多扫描.
[更新]如果指定了Didier Spezia,您需要Redis 2.8才能使用* SCAN命令.