GitXplorerGitXplorer
t

node-mmemoize

public
2 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
1ae7629a23d4494784af1f88775fb35fe861b66a

Fix var name typo

ttmuellerleile committed 12 years ago
Unverified
bcdf4619722c70511a0b282b36650e27e125b275

Add license

ttmuellerleile committed 12 years ago
Unverified
bb269b9f6f8118ecfcc826ab0a3185c01c6b9623

Bump version number

ttmuellerleile committed 12 years ago
Unverified
8ce6089f51bf880149e39569f06ddeedb33f476c

Replace node-memcached w/ memcached href

ttmuellerleile committed 12 years ago
Unverified
8b149d324731263cb4c55db88e721c20cd8d955f

Allow for using "embedded" (= `require`d) memcached instance

ttmuellerleile committed 12 years ago
Unverified
22050a757117f11dbc7fc9ce84f08aa57b290e32

BDD -> TDD

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)