simple-file-cache

a simple and easy to use file-based cache

MIT License

Downloads
9
Stars
1
Committers
3

Simple File Cache

a simple and easy to use file-based cache

Install

npm install @ahmadnassri/simple-file-cache

API

_(namespace)

Create a new cache name space

const simple = require('@ahmadnassri/simple-file-cache')

const cache = simple('my-awesome-app')

cache.set('foo', 'bar', 100)

set(key, value[, ttl])

Creates a cache record using the key:value pair, and optionally sets an expiry date using ttl in milliseconds.

cache.set('foo', 'bar', 100)

get(key)

retrieves a cache record identified with key, if the expiry time has elapsed, the record will be deleted and return a value of null

cache.get('foo')

process.env.SIMPLE_CACHE_DIR

path to store the cache records, defaults to $XDG_CACHE_HOME


Author: Ahmad Nassri • Github: @ahmadnassri • Twitter: @ahmadnassri