lru-cache-fs

2.0.1 • Public • Published

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

Dependencies (2)

Dev Dependencies (5)

Package Sidebar

Install

npm i lru-cache-fs

Weekly Downloads

2,943

Version

2.0.1

License

MIT

Unpacked Size

4.3 kB

Total Files

4

Last publish

Collaborators

  • ruyadorno