Skip to content

Instantly share code, notes, and snippets.

@smrchy
Created December 21, 2012 15:12
Show Gist options
  • Select an option

  • Save smrchy/4353390 to your computer and use it in GitHub Desktop.

Select an option

Save smrchy/4353390 to your computer and use it in GitHub Desktop.
# Redis ZSET to Leaderboard
#
# Transform a Redis ZREVRANGE result which should be something like this:
# `["userid123",1234,"userid567",952,"someotherUser",200]`
#
# Result is an array like this:
# [
# {"u":"userid123","s":1234},
# {"u":"userid567","s":952},
# {"u":"someotherUser","s":200}
# ]
#
#
_redisLeaderboardTransform = (zset) ->
for e,i in zset by 2
{u:e, s:parseInt(zset[i+1])}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment