Redis Hash: HSCAN
Redis HSCAN Command
HSCAN array of elements contains two elements, a field, and a value, for every returned element of the Hash.
Here are some common uses and scenarios for the "HSCAN" command:
- Large Hash Iteration: Efficiently iterate over large hashes without blocking the server.
- Data Retrieval: Retrieve subsets of fields and values from a hash incrementally.
- Pattern Matching: Filter fields and values based on patterns using the MATCH option.
- Batch Processing: Process hash entries in manageable chunks to avoid overloading the client or server.
- Dynamic Data Inspection: Inspect and analyze hash data progressively, which is useful for debugging or monitoring.
Syntax:
HSCAN key cursor [MATCH pattern] [COUNT count]
Available since
2.8.0.
Return Value
return a two elements multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements.
Return Value Type
Integer
Example: Redis HSCAN
Iteration of an Hash value.
127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python" lang4 "GoLanguage" OK 127.0.0.1:6379> HSCAN langhash 0 1) "0" 2) 1) "lang1" 2) "PHP" 3) "lang2" 4) "JavaScript" 5) "lang3" 6) "Python" 7) "lang4" 8) "GoLanguage"
Previous:
HVALS
Next:
Redis Lists BLPOP
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-hscan-key-cursor.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics