With Redis (I’m using Python redis) you can scan keys like this:
keys = redis_client.scan_iter(match='{string}*')
However how would I do this if I want to get all keys excluding a certain string? So in this example I would like all keys not starting with ‘{string}’.
2
Answers
According to the documentation, the Redis
SCAN
command uses glob-style syntax. There is no way in that syntax to specify all strings that don’t start with a certain string. So you can’t do it.Redis’ pattern matching is glob-like so there’s no real way to do that. Instead, you can match
*
and use Python’s capabilities (e.g.not str.startswith('s')
)