0.0.3 • Published 8 years ago

memcache.js v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

memcache.js

A simple memory cache module!

Method

  • MemCache#set(key, value, options)
  • MemCache#get(key, makeValueFunc, options)
  • MemCache#cache()

example:

var memcache = require('memcache.js');

function makeValueFunc() {
  return new Promise(function (resolve, reject) {
    resolve('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  });
}

memcache.get('key', makeValueFunc, {expire: 6000}).then(function (v) {
  console.log(v, 1);
});

memcache.get('key', makeValueFunc, {expire: 8000}).then(function (v) {
  console.log(v, 2);
});

setInterval(function () {
  console.log(memcache.cache());
}, 2000);