Treat window.localStorage more like Redis
```javascript
store = new Depot
```
-
The basics –
get
,set
,del
:// tk
-
Store non-string values:
store.set('album', {album: "Mass Romantic", band: "The New Pornographers", year: 2000});
-
Array methods:
store.set('extracurriculars', [ 'Yankee Review', 'French Club', 'Model UN', '2nd Chorale' ]);
-
pop
:store.pop('extracurriculars') -> '2nd Chorale' // 'numbers' = ['Yankee Review', 'French Club', 'Model UN']
-
push
:store.push('extracurriculars', 'Kite Flying Society') // 'numbers' = ['Yankee Review', 'French Club', 'Model UN', 'Kite Flying Society']
-
len
:// tk
-
-
Simple counter manipulation with
incr
anddecr
:// key 'bottlesOfBeerOnTheWall' = 99 store.decr('bottlesOfBeerOnTheWall') -> 98 store.incr('visitors', 10) -> 10
-
Key prefixing:
var store = new Depot('myapp'); value = store.get('username'); // same as: window.localStorage.getItem('myapp:username');
- Doesn't emulate localStorage for older browsers (and never will)
- Events API