Skip to content

Instantly share code, notes, and snippets.

@hash-bang
Created September 22, 2016 04:19
Show Gist options
  • Save hash-bang/e3ea31616fad3f88e7a9bcac5d77167a to your computer and use it in GitHub Desktop.
Save hash-bang/e3ea31616fad3f88e7a9bcac5d77167a to your computer and use it in GitHub Desktop.
Memcached demo
var _ = require('lodash');
var async = require('async-chainable');
var memcached = require('memcached');
var cache = new memcached('127.0.0.1:11211');
async()
.forEach(_.shuffle(_.times(1000, i => i)), function(next, i) {
cache.get('demo.' + i, function(err, res) {
console.log('Hello', i, res);
cache.set('demo.' + i, 'VAL-' + _.random(1000, 9999), 120, function(err, res) {
if (err) return next(err);
setTimeout(next, i);
});
});
})
.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment