title: Redis creating keys efficiently
body: <p>I am trying to store some data in redis.</p>
  
  <p>Consider following example. </p>
  
  <p>A person has different cars owned in different years. </p>
  
  <p>Currently I am storing keys like this - </p>
  
  <pre><code>cars:johndoe:1991:mercedes model s1 engine v1
  cars:johndoe:1992:mercedes model s1 engine v1
  cars:jane:1992:BMW model s2 engine v2
  cars:foobar:1991:honda model s3 engine v3
  </code></pre>
  
  <p>Advantage of this is that - I can use wildcard with key to fetch different data.
  e.g </p>
  
  <pre><code>1. all cars bought in 1991
  keys cars:*:1991:*
  
  2. all cars owned by johndoe
  keys cars:johndoe:*
  </code></pre>
  
  <p>etc.</p>
  
  <p>But as per redis documentation, <code>keys</code> command with wildcard is not efficient, as it searches all keys.<br>
  So I decided to use sets for this data. 
  But to achieve same results like above, I need many different types sets e.g</p>
  
  <pre><code>1. sadd cars cars:johndoe:1991:mercedes cars:johndoe:1992:mercedes cars:jane:1992:BMW cars:foobar:1991:honda
  2. sadd cars:johndoe cars:johndoe:1991:mercedes cars:johndoe:1992:mercedes
  3. sadd cars:jane cars:jane:1992:BMW 
  4. sadd cars:foobar cars:foobar:1991:honda
  5. sadd cars:1991 cars cars:johndoe:1991:mercedes  cars:foobar:1991:honda
  </code></pre>
  
  <p>This way, I need to add &amp; remove many keys for single operation.</p>
  
  <p>Is this the only way ? Please let me know if there is any more efficient workaround for this. </p>
  
  <p>Thanks in advance. </p>