
memcached-multiplex
combine concurrent gets for the same keys into one get/multiget to the server
var Memcached = require('memcached');
var multi = require('memcache-multiplex');
var getter = multi(new Memcached('127.0.0.1:11211'));
getter.get('hi',function(err,v){
console.log('the value of hi',v)
})
getter.get('hi',function(err,v){
console.log('the value of hi',v)
})
getter.get('hi',function(err,v){
console.log('the value of hi',v)
})
getter.getMulti(['a','b'],function(){
});
getter.getMulti(['b','c'],function(){
});
getter.getMulti(['a','c'],function(){
});
multi = require('memcached-multiplex')(new Memcached(hosts));
- this module exports a function
- if you call this function with a memcached client you will get an object with getter methods
.get(key,cb)
gets the key
.getMulti([key, key2],cb)
get multiple keys
.stats
{
get:{keys:0,calls:0},
multi:{keys:0,requested:0,calls:0,made:0}
}
rant! if you use node you should not make multiple concurrent gets for the same external resources. this applies to databases web services whatever.