title: Redis sorted set ordered by time with a score as well
body: <p>I'm trying to use a <code>Redis sorted set</code> with a score, sorted by time.</p>
  
  <p>My current idea is to use a <code>Lua script</code> and <code>pack</code> the time and value in the score field, using <code>MessagePack</code> (<code>msgpack</code>).</p>
  
  <ul>
  <li>The time value is taken from <code>datetime.utcnow()</code> in Python that looks like this: <code>1417395600</code>.</li>
  <li>The score could have pretty much any kind of value.</li>
  </ul>
  
  <p>So my questions are:</p>
  
  <ol>
  <li>Is it possible to pack those kind of values? Redis' sorted set seems to be limited to floats, unless I'm mistaken.</li>
  <li>Would this keep the time order?</li>
  </ol>
  
  <p>If you have any other idea for me on how to do this, please let me know. I would strongly prefer not to use another table just to store the score of each client...</p>
  
  <p>PS: I actually do not care about the time, I simply need the scores (values) to be ordered by time, to use the sorted set as a leaderboard.</p>