Created
September 22, 2016 04:19
-
-
Save hash-bang/e3ea31616fad3f88e7a9bcac5d77167a to your computer and use it in GitHub Desktop.
Memcached demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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