title: Best way to pass array of objects to Redis Lua script
body: <h2>Question</h2>
  
  <p><em>What is a best practice to pass an array of objects into Lua script? Is there any better way than converting objects to JSON and parse them with <code>cjson</code> within a script?</em></p>
  
  <h2>More context</h2>
  
  <p>I have streaming application which keeps it state in Redis. Every second we get 5-100 events, all operations are done within single transaction in order to boost performance like following:</p>
  
  <pre><code>RedisCommands&lt;String, String&gt; cmd = getOrCreateRedisClient();
  cmd.multi();
  for (Event event: listOfEvents) {
     cmd.sadd("users", event.getUserId());
     cmd.sadd("actions", event.getActionId());
     cmd.incrbyfloat("users:" + event.getUserId(), event.getImpact());
  }
  cmd.exec();
  </code></pre>
  
  <p>Now I have to move this logic to Lua scripts. I suppose it also will be faster to pass an array of events to Lua script instead of making up to 100 script invocations (one per event). <em>Am I right? What is the best way to pass list of events to Lua script?</em></p>