https://github.com/muke1908/as-store
localstorage wrapper with Async write support
https://github.com/muke1908/as-store
Last synced: 8 months ago
JSON representation
localstorage wrapper with Async write support
- Host: GitHub
- URL: https://github.com/muke1908/as-store
- Owner: muke1908
- Created: 2019-03-28T12:44:35.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-07T13:41:05.000Z (almost 7 years ago)
- Last Synced: 2025-03-27T16:17:29.348Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Asynchronous local storage (Write through cache)
A local storage wrapper, that helps to write data to disk asynchronously. It uses in-mem cache for faster "READ"
## Install
`npm install as-store`
## Usage
### Methods:
1) `AsStore.setItem(key, value)` - set `value` for `key` in `as-store`
2) `AsStore.getItem(key)` - lookup data for `key` from `as-store`
3) `AsStore.removeItem(key)` - remove `key` from `as-store`
4) `AsStore.flush()` - flush all the data from `as-store`
5) `AsStore.onWriteComplete(function)` - attach handler to disk "WRITE". `funciton` will be called when writing to disk.
### Why it's fast and non-blocking ?
`setItem` - doesn't write the data to disk immediately. Non-blocking. Process multiple write operation at once (with 500ms throttling).
`getItem` - doesn't read data from disk. It maintain a hash map in client. It directly returns data from memory.