fs-simple-cache

1.2.0 • Public • Published

fs-simple-cache

npm version

Simple filesystem cache for node.

Usage

npm install fs-simple-cache --save-dev
const path = require('path')
const Cache = require('fs-simple-cache')
const cache = new Cache({
  cacheDirectory: path.resolve('.cache') // => optional, when not provided will use a temporary folder
})

let key = 'some content'
let content

// using json and gzip
if (!content = cache.get(key).content) {
  content = 'do some intensive stuff to create the content'
  cache.put(key, { content })
}

// using raw data and without gzip
const gzip = false
if (!content = cache.get(key, gzip)) {
  content = 'do some intensive stuff to create the content'
  cache.put(key, content, gzip)
}

// do something with the content

// delete the content
cache.delete(key, gzip)

// delete cache directory
cache.delete()

Readme

Keywords

Package Sidebar

Install

npm i fs-simple-cache

Weekly Downloads

18

Version

1.2.0

License

ISC

Unpacked Size

3.27 kB

Total Files

3

Last publish

Collaborators

  • lazabogdan