Skip to content

pft/url-data-cache-async

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-cache

Cache data from a url request.

Forked from url-data-cache.

Main differences: This library is async. Does not itself remove expired data.

  import urlCacheInstance from 'url-data-cache';
  const urlDataCache = urlCacheInstance('my-app');
  // or

  const urlDataCache = require('url-data-cache')('my-app');

  // methods: drop, info, put

  // put data into cache, expiring after one hour
  urlDataCache.put(url, data, 3600);

  // get info from cache
  const {exists, expired, dataPath, basePath, metaPath, url } = await urlDataCache.info(url);
  if (exists && !expired) {
    // Do something with dataPath
  } if (exists && expired) {
    await urlDataCache.drop(url);
  }
  // NOTE if exists is false, expired is always 'n/a'

About

Cache data from a url request.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%