What is better from a performance perspective? How to use them smart?
I have hash entities in redis. One hash name has about 150K key-values pairs ( this is a requirement) And I have a NodeJS application that processes the response and etc. Will use libs like "node-redis-scan" eachScan(), "redis" hvals()
I can use:
"redis" hvals().
REDIS COMMAND: hvals 'my hash name'
and get 150K values in one call
"node-redis-scan" eachScan() with options.
REDIS COMMAND: hscan 'my hash name' 0 MATCH * COUNT 15000
will work with the cursor till its value is 0 and filter the result to fetch the values only on a code level.
Which option is better and when?
IMHO I wouldn't use HVALS unless I clearly know that the size of the hashmap is very little.
Why ? The same answer as why not to use KEYS command: it can block the main thread if there is a big response. HSCAN returns key and value, perhaps more than you need. But because it's interactive it scales the answer and doesn't block the main thread for long.
I have developed a little library in Java (search InterruptedJedisLocks in github) and I have used many times HSCAN and none HVALS nor HKEYS once.