0.0.7 • Published 8 years ago

browser-cache v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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
0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago