PASSWORD RESET

Your destination for complete Tech news

How to get all available keys in Redis?

565 0
< 1 min read

To get all available keys in Redis, you can use the “KEYS” command. This command takes a pattern as an argument and returns all keys that match the pattern.

You can run the command in the redis-cli by typing:

$ redis-cli KEYS pattern

where “pattern” is the pattern you want to match. For example, to get all keys that start with “user:”, you can use the pattern “user:*”.

You can also use the scan command which is more efficient than KEYS command for large data sets.

$ redis-cli SCAN 0 MATCH pattern

In python redis library

import redis
r = redis.Redis()
keys = r.scan_iter("pattern")

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.