fs-cash

2.0.0 • Public • Published

fs-cash 💰

A simple fs-persisted json cache.

npm version Build Status Coverage Status dependencies Status

Quick start

npm install --save fs-cash
const cache = require('fs-cash');
cache.set('key', 'value').then(() => {
  // saved
});

Everything is persisted to process.cwd() / .cash

cache.get('key').then((value) => {
  // value = key
});

API

del( key:string ) :Promise

Delete cached value.

get( key:string ) :Promise<*>

Get cached value.

memoize( func:function [, serialize:function ] ) :function

Memoize a function.

const sqrt = cache.memoize(Math.sqrt);
sqrt(16).then((value) => { /* 4 */ });

set( key:string, value:* [, options:object] ) :Promise

Set cached value.

options.ttl :number

Cached value will expire after ttl (time to live) milliseconds.

reset( key:string ) :Promise

Reset cache and delete cache file.

Readme

Keywords

Package Sidebar

Install

npm i fs-cash

Weekly Downloads

5

Version

2.0.0

License

MIT

Last publish

Collaborators

  • moeriki