skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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'))

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search