Help Center/ GeminiDB/ GeminiDB Redis API/ FAQs/ Database Usage/ Why Is the Key Not Returned Using Scan Match?
Updated on 2023-05-30 GMT+08:00

Why Is the Key Not Returned Using Scan Match?

Symptom

As shown in the following figure, the value of key is test and exists in the database. However, no data is returned using this scan match command.

139.9.177.148: 8635> scan 1 match tes*
1) "21"
2) (empty list or set)
139.9.177.148: 8635> get test
"abc"
139.9.177.148:8635>scan 0 match tes*
1) "21"
2) (empty list or set)
139.9.177.148: 8635>

Possible Causes

The MATCH command is used to iterate elements that only match a specified pattern. Pattern matching is performed after the command obtain elements from the data set and before the elements are returned to the client. If all the extracted elements do not match the pattern, no element is returned.

Solution

If multiple scans are performed, the iteration is complete when the returned cursor is 0. The cursor returned from the last scan is used for the next scan.