Help Center> Distributed Cache Service> FAQs> Redis Commands> How Do I Find Specified Keys and Traverse All Keys?
Updated on 2022-08-10 GMT+08:00

How Do I Find Specified Keys and Traverse All Keys?

Finding Specified Keys

Big key and hot key analysis does not support key searching with specified conditions. To find keys with the specified prefix or suffix, use the SCAN command.

For example, to search for keys that contain the letter a in a Redis instance, run the following command in redis-cli:

./redis-cli -h {redis_address} -p {port} [-a password] --scan --pattern '*a*'

Traversing All Keys

Do not use the KEYS command to traverse all keys of an instance because the KEYS command is complex and may block Redis. To traverse all keys in a DCS Redis instance, run the following command in redis-cli:

./redis-cli -h {redis_address} -p {port} [-a password] --scan --pattern '*'

For details about the SCAN command, visit the Redis official website.

Redis Commands FAQs

more