Skip to content

dailyrandomphoto/a-cachify

Repository files navigation

a-cachify

NPM Version LICENSE Build Status code style: prettier

Easily add a cache layer to any function.

Installation

npm install a-cachify

Usages

const { cachify, join } = require("a-cachify");
const Cache = require("cache-module");
const cache = new Cache();

let doSomething = function (arg1, arg2) {
  result = heavyWork(arg1, arg2);
  return result;
};

// Add a cache layer
doSomething = cachify(cache, doSomething, join);

doSomething(1, 2);
doSomething(1, 2); // return the cached result

API

cachify (cache, fn [ , keyMaker ][ , thisarg ])

add a cache layer to the function.

apply (cache)

wrap (cache)

join

joinN

License

Copyright (c) 2020 dailyrandomphoto. Licensed under the MIT license.

About

Easily add a cache layer to any function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published