GitXplorerGitXplorer
t

node-mmemoize

public
2 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
5457c0ce65c953392501d4e829b3118d9a369e83

Add .jshintignore

ttmuellerleile committed 12 years ago
Unverified
ec3b7c6026a191596cd872411669bb224de2b2e3

Fix spelling

ttmuellerleile committed 12 years ago
Unverified
d3421f66b0dfef74dff465f3c588f58ed546ad8b

Add license info to package.json, too

ttmuellerleile committed 12 years ago
Unverified
635695e19c66d2d83a63df73500833b10d40ca55

Bump version number

ttmuellerleile committed 12 years ago
Unverified
401a8f2144aa81cf0654daad85b78321b6aeabd7

Add jshint-based style fixes for tests, too

ttmuellerleile committed 12 years ago
Unverified
43b09d073db19ebfe1cfef6e85e90d3b64e5b2e7

Add .jshintrc and jshint-based coding style fixes

ttmuellerleile committed 12 years ago

README

The README file for this repository.

node-mmemoize

Memoize asynchronous function calls using memcached

Installation

$ npm install mmemoize

Usage

var mmemoize = require('mmemoize');

var mmemoizer = mmemoize('localhost:11211' /*, ..., config */);

// or:
// var Memcached = require('memcached'),
//     memcached = new Memcached('localhost:11211' /*, ...*/),
//     mmemoizer = mmemoize(memcached /*, config */);

var a = function (/* someArguments, */ callback) {
   // some potentially expensive computations, database fetches etc.
   // ...
   return callback(potentialErrors, theResult);
}

a = mmemoizer.memoize(a, 'a' /*, customTTL */);
a(/* someArguments, */ function (err, result) {
   // process results
   // ...
});

// just in case:
a = a.dememoize(); // or: a = mmemoizer.dememoize(a);

Configuration

Send config object as the last parameter of mmemoize(), use the following options:

  • ttl: Default key TTL in seconds; default: 120
  • hashAlgorithm: Algorithm used for hashing function arguments in memcached keys, set to null for no hashing at all, for possible values see Node's crypto documentation; default: sha1

Deployment dependencies

Tests

  • using mocha
  • with running memcached instance (of course)
  • $ mocha

License

MIT (see LICENSE)