lru-cache-fs

v2.0.1
Extends lru-cache to add file system support
cache lru-cache env-paths fs

lru-cache-fs

NPM version Build Status MIT license

Extends lru-cache to add file system support.

Install

npm install lru-cache-fs

Usage

Retrieve cache:

const Cache = require('lru-cache-fs')

const cache = new Cache({
    max: 100,
    cacheName: "cache" // filename ref to be used
});

By default it will use os specific paths, using env-paths.

Then retrieve/set items using:

cache.get('some-item') // returns whatever was stored
cache.set('some-new-item', 'foo') // sets new item and stores cache sync to fs

The fsDump() method exposes an API that allows you to persist the current cache on your file system:

cache.fsDump()

All other methods from lru-cache should be available, e.g:

cache.dump() // retrieves dump of current cache memory

License

MIT © 2019 Ruy Adorno

npm i lru-cache-fs

Metadata

  • MIT
  • Whatever
  • Ruy Adorno
  • released 11/23/2019

Downloads

Maintainers