Skip to content

Instantly share code, notes, and snippets.

@goofyahead
Last active December 28, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofyahead/7459592 to your computer and use it in GitHub Desktop.
Save goofyahead/7459592 to your computer and use it in GitHub Desktop.
Pagination of elements with redis
var likes = [1,1,1,4,5,6,7,8,9];
var response = false;
client.sadd('temp:comparator', likes, function (err, data) {
client.sdiff('temp:comparator', 'set:zara', function (err, data) {
console.log(data);
if (data.length > 0) {
client.sadd('set:zara', data, redis.print);
client.del('temp:comparator', redis.print);
data.forEach(function (elem) {
client.rpush('brand:ids:list:zara', elem, function (err, data) {
if (data >= 5 && ! response) {
response = true;
client.lrange('brand:ids:list:zara', 0, 4, function (err, data) {
console.log(data);
});
}
});
});
}
});
});
likes = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment