npm

Need private packages and team management tools?Check out npm Orgs. »

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

install

npm i json-simple-cache

Downloadsweekly downloads

2

version

1.0.12

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability