Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 845 Bytes

File metadata and controls

43 lines (33 loc) · 845 Bytes

Store

Storage Module, the storage encapsulation of localStorage/sessionStorage/Memory, for the consistency interface.

Install

bower install Storejs

Usage

var store = new Store({
  session: true // -> use sessionStorage or local: true->use  localStorage
});

store.set('name', switer);
store.get('name'); // return "switer"
store.remove('name'); // now it's empty

store.set('data', {user: 'switer'}, 60); // store value with expire of 60 seconds

API

instance options:

{
    local: {Boolean},  // use localstorage
    session: {Boolean} // use session storage
    namespace: {String}// use namespace 
}

instance methods:

get(key) getter

set(key, value, expire) setter

remove(key) remove the specify cache with the key

removeExpired() remove all expired cache