json-simple-cache

1.0.12 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i json-simple-cache

Weekly Downloads

2

Version

1.0.12

License

MIT

Unpacked Size

5.63 kB

Total Files

5

Last publish

Collaborators

  • vinicioslc