url-data-cache

1.22.0 • Public • Published

url-cache

Cache data from a url request.

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

  // or

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

  // then


  // get from cache (also delete expired)
  const cachedData = urlDataCache.get(url);
  if(cachedData) return resolve(cachedData);

  // put to cache
  urlDataCache.put(url, htmlData, '1 hour');

Supported time units:

  • n second
  • n seconds
  • n minute
  • n minutes
  • n hour
  • n hours
  • n month
  • n months

where n is a number

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i url-data-cache

    Weekly Downloads

    2

    Version

    1.22.0

    License

    ISC

    Unpacked Size

    39.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • fantasyui.com