title: How to count number of keys with value matching a pattern in redis-py?
body: <p>How can I count number of keys with value matching a pattern in redis-py?
  I've found methods scan, scan_iter but they search using the pattern on the name of the key.</p>
  
  <p>Example of what I need:</p>
  
  <pre><code>r = redis.Redis(host='localhost', port=6379, db=0)
  r.set('key1', 'bar')
  r.set('key2', 'bar')
  r.set('key3', 'bar')
  keys_num = len(list(r.unknown_scan(match='bar')))
  print(keys_num)
  &gt;&gt;3
  </code></pre>
  
  <p>I looked into documentation but could not find anything suitable. I thought about pulling all the keys and values and then loop them one by one counting values matching my pattern, but it looks inefficient, there should be a better way. </p>