Socket
Socket
Sign inDemoInstall

browser-cache

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    browser-cache

browser cache processed API


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
2.66 kB
Created
Weekly downloads
 

Readme

Source

cache

browser cache processed API

DEMO

view example

usage

It is base on localStorage and sessionStorage, please running in browser.

  $ npm install browser-cache

Include js in /dist by tag , you can also require('browser-cache')

Than

  Cache.init(config); // run init function
config
  // default config
  {
    limit: 3600, // time limit (second)
    overdue: 1, // you can also set overdue at the end of days number (prior to limit)
    prefix: 'cache' // prefix in storage
  }
methods
  Cache.deal(name, callback, isSession); // deal with old data
  Cache.save(name, value, isSession); // save new data
  Cache.remove(name, isSession); // remove that keyvalue from localStorage, or not incoming false to remove all prefix data

callback will return two arguments, you can use them like that

  Cache.deal('order', (overdue, data) => {
    if(data) {
      // deal with old data first
    }

    if(overdue || !data) {
      // make new data
      Cache.save(order, newdata);
    }
  });
develop
  $ make dev

FAQs

Last updated on 21 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc