Skip to content

Instantly share code, notes, and snippets.

@stockholmux
Created May 17, 2018 18:11
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 stockholmux/712f02c599cfcc5c6cebafeb37cc87e4 to your computer and use it in GitHub Desktop.
Save stockholmux/712f02c599cfcc5c6cebafeb37cc87e4 to your computer and use it in GitHub Desktop.
const redis = require('redis');
const client = redis.createClient(/* your configuration info */);
const multi = client.multi();
// Create three articles with randomized hits representing user views
let id = 100000;
while(id--) {
multi.SETBIT('article1:today', id, Math.round(Math.random(1)));
multi.SETBIT('article2:today', id, Math.round(Math.random(1)));
multi.SETBIT('article3:today', id, Math.round(Math.random(1)));
}
multi.exec(err => {
// done
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment