Skip to content

Instantly share code, notes, and snippets.

@chbrown
Created November 2, 2012 05:00
Show Gist options
  • Select an option

  • Save chbrown/3998808 to your computer and use it in GitHub Desktop.

Select an option

Save chbrown/3998808 to your computer and use it in GitHub Desktop.
ZPOP for Node.js redis
redis.RedisClient.prototype.zpop = function(key, withscores, callback) {
if (callback === undefined && typeof(withscores) === 'function') callback = withscores;
this.multi().
zrange(key, 0, 0, withscores).
zremrangebyrank(key, 0, 0).
exec(function(err, replies) {
if (callback) callback(err, replies ? replies[0] : null);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment