fs-cache-freezer

1.0.0 • Public • Published

Cached

Stores data in files. On retrieval you may specify a maximum age, and if you retrieve an older or non-existent file you will get nothing back.

API

cache = new Cached('/tmp');

####set(key, data) => Promise()

Stores the given data under the given string key.

####get(key) => Promise(data)

Gets the data stored under the given key, regardless of age. Throws an error if the data is not there.

####get(key, maxAgeMilliseconds) => Promise(data)

Gets the data stored under the given key, as long as the data is less than a certain number of milliseconds old.

####FOREVER

This is a constant that, if used as a TTL, says that age is of no concern.

####executor(funct)

This utility wraps a function. It stringifies the function arguments and uses them as a key for caching results. When the wrapped function is called, a cached result is used, if possible, else the original function is called. The time limit becomes the new first argument, followed by the original arguments.

/fs-cache-freezer/

    Package Sidebar

    Install

    npm i fs-cache-freezer

    Weekly Downloads

    1

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • bitdivine