title: Redis lua when to really use it?
body: <p>I've started to research and play a bit with lua and have found it to be great when wanting to grab ranges of keys. Ex:</p>
  
  <pre><code>business:5:visits:2013-11-12
  business:5:visits:2013-11-13
  etc
  </code></pre>
  
  <p>With lua I only have to send one command to redis instead of the complete range of dates.</p>
  
  <p>Now I'm thinking about converting more of our logic and move it onto Redis. </p>
  
  <p>Take our message storing process which currently looks like this:</p>
  
  <pre><code>// create a new unique id
  redisClient.incr(Config.messageId, function(err, reply) {
      var messageId = reply.toString();
      var timestmp = Date.now();
  
      // push message
      redisClient.zadd(Config.history + ':' + obj.uid + ':' + obj.channel.replace(/\s+/g, ''), timestmp, messageId);
  
      // store the message data by messageId
      redisClient.hmset(Config.messageHash + ':' + messageId, {
          'user_id': obj.uid,
          'text_body': "some text",
          'text_date': timestmp,
      });
  
  
      // set expires
      redisClient.expire(Config.history + ':' + obj.uid + ':' + obj.channel.replace(/\s+/g, ''), Config.messageExpire);
      redisClient.expire(Config.messageHash + ':' + messageId, Config.messageExpire);
  
  
      // add to mysql-sync queue
      redisClient.RPUSH(Config.messageMySQLSyncQueue, Config.messageHash + ':' + messageId);
  
  });
  </code></pre>
  
  <p>The above could easily be converted into lua, but is it worth it for performance?</p>
  
  <p>Would it be faster to write this in Lua instead and only have to issue 1 command to Redis? Would it cause problems with blocking other commands?</p>