redis hscan 命令不能限制计数 [英] redis hscan command cannot limit the counts
问题描述
我的redis版本:3.0.2
散列数据如下图所示.
键名:测试
内容(值):
1) "xx1"
2) 1"
3) "xx2"
4) "2"
5) "xx3"
6) 3"
7) "xx4"
8) 4"
9) "xx5"
10)"5"
使用 commond -->HSCAN 测试 0 COUNT 2
Redis 返回每个键和值,而不是 2 个键和值中的第一个!
my redis version:3.0.2
Hash data as below show.
key name:test
contents(values):
1) "xx1"
2) "1"
3) "xx2"
4) "2"
5) "xx3"
6) "3"
7) "xx4"
8) "4"
9) "xx5"
10)"5"
use commond -->HSCAN test 0 COUNT 2
Redis return every key and value, not the first of 2 keys and values!
推荐答案
SCAN 的 COUNT 选项不限制返回的键值的数量.
COUNT option for SCAN does not limit the number of key-values returned.
用于强制命令增加返回的key-value个数.
It is used to force the command to increase the number key-values returned.
Redis COUNT 选项 doc:
Redis COUNT option doc:
- 当迭代 Sets 编码为 intsets 时(小集合只由整数),或编码为 ziplists 的哈希和排序集(小哈希和由小的个体值组成的集合),通常所有的无论 COUNT 是多少,都会在第一次 SCAN 调用中返回元素价值.
因此,从 HSCAN test 0
命令的结果中获取前两个值.
So, get first two values from the result of HSCAN test 0
command.
这篇关于redis hscan 命令不能限制计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!