title: Redis how to store associative array? Set or Hash or List?
body: <p>I'm a bit confused with all the available storing options of Redis.
  I want to do something simple and I don't want to over engineer it.
  I'm working with <code>phpredis</code> and <code>Redis v2.8.6</code>.</p>
  
  <p>I have this simple associative array that I need to store. I also need to be able to retrieve an item by its key and loop over all the items.</p>
  
  <pre><code>$a = array(
      '12345' =&gt; array(
          'name' =&gt; 'Post A',
          'val2' =&gt; 'blah blah',
          'val3' =&gt; 'blah blah blah',
      ),
      '54321' =&gt; array(
          'name' =&gt; 'Post B',
          'val2' =&gt; 'blah blah',
          'val3' =&gt; 'blah blah blah',
      ),
      '998877' =&gt; array(
          'name' =&gt; 'Post C',
          'val2' =&gt; 'blah blah',
          'val3' =&gt; 'blah blah blah',
      )
  );
  </code></pre>
  
  <p>So what I was doing till now was using <code>hash</code> type. storing my array like this:</p>
  
  <pre><code>foreach ($a as $key =&gt; $value) {
      $this-&gt;redis-&gt;hSet('posts', $key, json_encode($value));
  }
  </code></pre>
  
  <p>Like that I could access the key easily like this:</p>
  
  <pre><code>public function getPost($postId)
  {
      return json_decode($this-&gt;redis-&gt;hGet('posts', $postId), true);
  }
  
  // This is returning the information of Post A
  $post = getPost(12345);
  </code></pre>
  
  <p>But now I need to loop over all the posts I don't know how to do it and if I can do it with my current structure. I don't know if I need to store all the <code>post_id</code> in another list to be able to loop over all the posts?</p>
  
  <p>So my question is which data type(s) should I use to store my list of posts, allowing me to fetch a single post by its id and looping over all the posts?</p>
  
  <p>Thanks, 
  Maxime</p>