1.0.7 • Published 6 years ago

noodle-cache v1.0.7

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

noodle-cache

Overview

A simple class for caching anything that it processes!

Usage

// app.js
import Cache from 'noodle-cache';

// cache for 60s
const responseCache = new Cache(60);

function fetchData() {
  const callApiCallback = () => callApi();
  const requestHash = some_unique_key_representing_the_request;

  ...

  // either returns the cached item, or makes the call, stores the result, and returns new data
  return responseCache.processItem(requestHash, callApiCallback);
}

Notes

  • processItem is an async function
  • processItem will cache any response, including errors
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago