Package Exports
- flash-store
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (flash-store) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
FLASH-STORE
FlashStore is Key-Value persistent storage with easy to use ES6 Map-like API(both Async and Sync support), powered by LevelDB and TypeScript.

REQUIRES
- Node.js v10 or above
EXAMPLES
Try the following command
npm install
npm run demoThe basic function as follows:
import { FlashStore } from 'flash-store'
const flashStore = new FlashStore('flashstore.workdir')
await flashStore.set(1, 'a')
console.log(`key: 1, value: ${await flashStore.get(1)}`)
// Output: 'a'
await flashStore.del(1)
console.log(`key: 1, value: ${await flashStore.get(1)}`)
// Output: undefinedAPI Reference
FlashStore
FlashStore implments the Standard ES6 Map API with Async modification:
/**
* ES6 Map API with Async
*/
export interface AsyncMap<K = any, V = any> {
[Symbol.asyncIterator]() : AsyncIterableIterator<[K, V]>
size : Promise<number>
clear () : Promise<void>
delete (key: K) : Promise<void>
entries() : AsyncIterableIterator<[K, V]>
get (key: K) : Promise<V | undefined>
has (key: K) : Promise<boolean>
keys () : AsyncIterableIterator<K>
set (key: K, value: V) : Promise<void>
values () : AsyncIterableIterator<V>
}
class FlashStore<K, V> implments AsyncMap<K, V> {}FlashStoreSync
FlashStoreSync implments the Standard ES6 Map API:
class FlashStoreSync<K, V> implments Map<K, V> {}- You get a sync API at the cost of all your data have to be kept in memory.
- The data will be async writting back to disk for persistant storage in background.
- The performance of
FlashStoreSynccan be expected high because it's all in memory.
DOCUMENT
SEE ALSO
- Node.js databases: an embedded database using LevelDB
- How to Cook a Graph Database in a Night - LevelGraph
- Graph database JS style for Node.js and the Browser. Built upon LevelUp and LevelDB.
- 浅析 Bigtable 和 LevelDB 的实现
CHANGELOG
v0.17 master 2019
v0.16 May 2019 - SnapDB as Backend
v0.14 May 2019 - RocksDB as Backend
v0.12 Jan 2019 - LevelDB as Backend
- Use LevelDB as backend to skip the compiling when install.
- Using leveldb official typings from
@types/
v0.7 Aug 2018 - Nosql-LevelDB as Backend
- Use nosql-leveldb as backend to prevent segfault.
v0.6 Jul 2018
- Upgrade to TypeScript 3.0
v0.4 Jun 2018
1. Refactor API to implenment ES6 Map interface
- Update the API to ES6
Map-like, the difference is that FlashStore is all async.
2. Add FlashStoreSync as a in-memory Write-back Cache for Flash-Store
Add a new class FlashStoreSync which is a in-memory full loaded Write-back Cache for Flash-Store:
- Writes directly to
cache, lazy writes tostore. - Reads from cache, never read-miss because cache have the full data of the store which will never expire.
- API of
FlashStoreSyncis the same as the ES6Map
v0.2 Sep 2017
Init version, API is LevelDB-like.
FAQ
Q: What's the difference between the flash-store and memory-card?
Short answer:
flash-storeis for save data to local flesystem.memory-cardis for save data to a distributed network storage, it can be serilized/deserilized safely by design.
Long answer:
flash-store and memory-card are all built by @huan, and they are all follow the ES6 Map API.
flash-store is using a no-sql local file database to maximum the performance, it can be used as a local database, or a local cache for whatever you want to catch from a network database.
memory-card is using a local file to store data in JSON format by default, however, it supports more distributed methods. Learn more from it's repository at here
AUTHOR
COPYRIGHT & LICENSE
- Code & Docs © 2017-now Huan (李卓桓) <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons
