async-cache-promise

2.0.2 • Public • Published

async-cache-promise Build Status

async-cache - but with promises

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install async-cache-promise --save

Usage

import co from 'co';
import setupAsyncCache from 'async-cache-promise';
 
co(function * (t) {
  let count = 0;
  const cache = setupAsyncCache({
    load: key => {
      count++;
      return Promise.resolve(key);
    }
  });
 
  console.log('this is not cached', yield cache.get(123));
  console.log('this is cached', yield cache.get(123));
});
 

Tests

npm install
npm test

Dependencies

  • async-cache: Cache your async lookups and don't fetch the same thing more than necessary.
  • bluebird: Full featured Promises/A+ implementation with exceptionally good performance
  • immutable-object-methods: Update normal plain javascript object, immutable style. Simlar to how immutable.js, seamless-immutable etc does it but a lot smaller and simpler.

Dev Dependencies

License

MIT

Generated by package-json-to-readme

Readme

Keywords

Package Sidebar

Install

npm i async-cache-promise

Weekly Downloads

890

Version

2.0.2

License

MIT

Last publish

Collaborators

  • kesla