title: Lua script to return efficient dictionary from Redis HGETALL call
body: <p>I need to use Redis <code>HMGET</code> from a Lua script and extract specific values in following code.
  But <code>redis.call('HMGET', table_key, hkey1, hkey2, ...)</code> return a flat array of <code>{hkey1, val1, hkey2, val2, ...}</code></p>
  
  <p>To extract values by key I wrote:</p>
  
  <pre><code>local function flat_map_get(flat_map, hash_key)
      local i = 1
      while flat_map[i] do
          if flat_map[i] == hash_key then
              return flat_map[i+1]
          end
          i = i+2
      end
  end
  </code></pre>
  
  <p>Of course, as usage grow, multiple calls to this function presented major performance drop.</p>
  
  <p><strong>What is an efficient way to read values from the flat array returned by <code>HMGET</code>?
  Or otherwise, to convert the returned value into a proper key-value table?</strong></p>