JSPM

  • Created
  • Published
  • Downloads 767
  • Score
    100M100P100Q99402F
  • License Apache-2.0

FlashStore is a Key-Value persistent storage with easy to use ES6 Map-like API(both Async and Sync support), powered by LevelDB and TypeScript.

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

Powered by LevelDB Powered by TypeScript Build Status NPM Version Downloads node

FlashStore is a Key-Value persistent storage with easy to use ES6 Map-like API(both Async and Sync support), powered by LevelDB and TypeScript.

flash store

EXAMPLES

Try the following command

npm install
npm run demo

The basic function as follows:

import { FlashStore } from 'flash-store'

const flashStore = new FlashStore('flashstore.workdir')

await flashStore.put(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: undefined

API 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> {}

DOCUMENT

See auto generated docs

SEE ALSO

  1. Node.js databases: an embedded database using LevelDB
  2. How to Cook a Graph Database in a Night - LevelGraph
  3. Graph database JS style for Node.js and the Browser. Built upon LevelUp and LevelDB.
  4. 浅析 Bigtable 和 LevelDB 的实现

CHANGELOG

v0.4 master (Jun 2018)

1. Refactor API to implenment ES6 Map interface

  1. 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:

  1. Writes directly to cache, lazy writes to store.
  2. Reads from cache, never read-miss because cache have the full data of the store which will never expire.
  3. API of FlashStoreSync is the same as the ES6 Map

v0.2 (Sep 2017)

Init version, API is LevelDB-like.

AUTHOR

Huan LI <zixia@zixia.net> (http://linkedin.com/in/zixia)

profile for zixia at Stack Overflow, Q&A for professional and enthusiast programmers
  • Code & Docs © 2017 Huan LI <zixia@zixia.net>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons