--- acl_categories: - '@read' - '@hash' - '@slow' arguments: - display_text: key key_spec_index: 0 name: key type: key - display_text: cursor name: cursor type: integer - display_text: pattern name: pattern optional: true token: MATCH type: pattern - display_text: count name: count optional: true token: COUNT type: integer - display_text: novalues name: novalues optional: true token: NOVALUES type: pure-token arity: -3 categories: - docs - develop - stack - oss - rs - rc - oss - kubernetes - clients command_flags: - readonly complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection. description: Iterates over fields and values of a hash. group: hash hidden: false hints: - nondeterministic_output key_specs: - RO: true access: true begin_search: spec: index: 1 type: index find_keys: spec: keystep: 1 lastkey: 0 limit: 0 type: range linkTitle: HSCAN railroad_diagram: /images/railroad/hscan.svg since: 2.8.0 summary: Iterates over fields and values of a hash. syntax_fmt: "HSCAN key cursor [MATCH\_pattern] [COUNT\_count] [NOVALUES]" title: HSCAN --- See [`SCAN`](/content/commands/scan.md) for `HSCAN` documentation. ## Required arguments
key The name of the key that holds the hash.
cursor The cursor value. Start an iteration with `0`, then use the cursor returned by each call as the argument to the next call.
## Optional arguments
MATCH pattern Only return fields whose names match the given glob-style pattern.
COUNT count A hint for the number of fields to return per iteration. The default is 10.
NOVALUES Return only the field names, without their values.
## Redis Software and Redis Cloud compatibility | Redis
Software | Redis
Cloud | Notes | |:----------------------|:-----------------|:------| | ✅ Standard
✅ Active-Active | ✅ Standard
✅ Active-Active | | ## Return information {{< multitabs id="hscan-return-info" tab1="RESP2" tab2="RESP3" >}} [Array reply](../../develop/reference/protocol-spec#arrays): a two-element array. * The first element is a [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings) that represents an unsigned 64-bit number, the cursor. * The second element is an [Array reply](../../develop/reference/protocol-spec#arrays) of field/value pairs that were scanned. When the `NOVALUES` flag (since Redis 7.4) is used, only the field names are returned. -tab-sep- [Array reply](../../develop/reference/protocol-spec#arrays): a two-element array. * The first element is a [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings) that represents an unsigned 64-bit number, the cursor. * The second element is an [Array reply](../../develop/reference/protocol-spec#arrays) of field/value pairs that were scanned. When the `NOVALUES` flag (since Redis 7.4) is used, only the field names are returned. {{< /multitabs >}}