Giter Site home page Giter Site logo

chrisnolan1992 / node-memcached-multiplex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uservidya/node-memcached-multiplex

0.0 2.0 0.0 106 KB

combine concurrent gets for the same keys into one get/multiget to the server

License: MIT License

JavaScript 100.00%

node-memcached-multiplex's Introduction

Build Status

memcached-multiplex

combine concurrent gets for the same keys into one get/multiget to the server

// first you need memcached. (or something that implements the methods get and getMulti)
var Memcached = require('memcached');
var multi = require('memcache-multiplex');

var getter = multi(new Memcached('127.0.0.1:11211'));

// all of these calls
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)
})

// make only one call to the memcache server

// get a,b
getter.getMulti(['a','b'],function(){

});

// get c but not b because im alredy fetching b
getter.getMulti(['b','c'],function(){

});

// no call is made im already requesting the keys im searching for.
getter.getMulti(['a','c'],function(){

});

// triggers 2 "getMulti" on the client driver.
// one for keys ['a','b'] and one for just key ['c']

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

  • stats is an object

  • it has stats that help you determine how well you are multiplexing

  • get

    • keys , how many single keys were requested from the memcached server
    • calls, how many keys were requested by calls to the function
  • multi

    • keys, how many keys were requested from the memcached server
    • requested, how many keys were requested by calls to getMulti
    • calls, how many calls to getMulti
    • made, how many calls to get multi resulted in fetching keys from the memcached server
  {
    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.

node-memcached-multiplex's People

Contributors

chrisnolan1992 avatar soldair avatar uservidya avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.