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!
Asked
Active
Viewed 2,633 times
1 Answers
3
COUNT option for SCAN does not limit the number of key-values returned.
It is used to force the command to increase the number key-values returned.
Redis COUNT option doc:
- When iterating Sets encoded as intsets (small sets composed of just integers), or Hashes and Sorted Sets encoded as ziplists (small hashes and sets composed of small individual values), usually all the elements are returned in the first SCAN call regardless of the COUNT value.
So, get first two values from the result of HSCAN test 0
command.

Anand S
- 1,068
- 9
- 22
-
Great!i see, when i put a large number of data into my hash set,the COUNT opthion worked!Thanks! – blueboy Dec 30 '15 at 02:19
-
2Even for large number of data COUNT will not always get you the accurate number of results. It can be equal or more than the COUNT. – Anand S Dec 30 '15 at 12:50