1.0.7 • Published 5 years ago

noodle-cache v1.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
5 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

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago