1.0.0 • Published 6 years ago

@ahmadnassri/simple-file-cache v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Simple File Cache

License version Build Status

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