json-simple-cache
v1.0.12
Published
A javascript library to do actions and store return in a json cache file. focused in small projects
Downloads
4
Maintainers
Readme
json-simple-cache
Example sending a web request if not be cached
const SimpleCache = require('json-simple-cache')
const cacheManager = new SimpleCache({
path: './caching/myfile',//path to your cache file
expiration: 20000 // your expiration time in milliseconds defaults is equals 1 week
})
const yourObjectIdentifier = "http://www.example.com/address?lat=2456.2151&lng=12125.1251"
var myResultCachedOrNot = cacheManager.doCachedRequest( yourObjectIdentifier, () => {
return myAwesomeWebRequest() // myAwesomeWebRequest will be returned if the cached identifier is not found or outdated
})
/*.....