1.0.12 • Published 6 years ago

json-simple-cache v1.0.12

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

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
})
/*.....