goodcache
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

GoodCache

A fifo based cache for Node and browser, uses the GoodCore library.

Usage

Install from npm.

Simple example

const fifo = new Cache<string>();
fifo.push("in fifo", "data");
fifo.hit("in fifo");

Simple caching of a class function

const test = new TestClass();
fifo.cache(test, "TestFn");
test.TestFn("test"); // returns some value
test.TestFn("test"); // returns cached value

Advanced caching of a class function

const test = new TestClass();
fifo.cache(test, "TestFn", (...args) => { return "some key string depending on the args"; } );
test.TestFn("test"); // returns some value
test.TestFn("test"); // returns cached value if the key function returns the same

For more look at the tests.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.7
    2
    • latest

Version History

Package Sidebar

Install

npm i goodcache

Weekly Downloads

9

Version

0.1.7

License

MIT

Unpacked Size

143 kB

Total Files

8

Last publish

Collaborators

  • jgoodgive