Giter Site home page Giter Site logo

huan / flash-store Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 4.0 349 KB

FlashStore is a high-performance Key-Value Persistent Local Database using ES6 Map's API (Async & Sync), Powered by LevelDB/RocksDB/SQLite and TypeScript.

Home Page: https://paka.dev/npm/flash-store

License: Apache License 2.0

TypeScript 57.36% JavaScript 35.80% Shell 6.83%
nosql database

flash-store's Introduction

flash-store

Powered by SQLite Powered by LevelDB Powered by RocksDB Powered by TypeScript ES Modules

NPM Version npm (next) GitHub Action TypeScript Downloads node

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

flash store

Requirements

  1. Node.js v10 or above

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

Supported Backend

Backend Flash Store Install NPM Command
LevelDB v1.0 npm install flash-store@1
SQLite v0.20 npm install [email protected]
Medea v0.18 npm install [email protected] (deprecated)
SnapDB v0.16 npm install [email protected] (deprecated)
RocksDB v0.14 npm install [email protected]
LevelDB v0.12 npm install [email protected]

SnapDB & Medea were all deprecated because of lots of unknown bugs.

API Reference

FlashStore

FlashStore implements the Standard ES6 Map API with Async modification, powered by async-map-like

/**
 * 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> implements AsyncMap<K, V> {}

FlashStoreSync

FlashStoreSync implements the Standard ES6 Map API:

class FlashStoreSync<K, V> implements Map<K, V> {}
  1. You get a sync API at the cost of all your data have to be kept in memory.
  2. The data will be async writing back to disk for persistent storage in background.
  3. The performance of FlashStoreSync can be expected high because it's all in memory.

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 的实现

Known Issues

  1. The gte and lte in options do not work property. (#4)

Version History

master v1.3 (Sep 12, 2021)

  1. ES Modules support (#93)
  2. Remove default workdir in FlashStore constructor.

v1.0 (Aug 16, 2021) LevelDB v7.0

Powered by LevelDB

LevelDB v7.0.0 support.

v0.20 Apr 2020 SQLite as Backend

  1. We hardcoded the key type to be string only in this version.
  2. We decide to try better-sqlite3 as it claim is very fast.
  3. The other alternates (would love to try in the future if necessary):
    1. TypeScript: sqlite
    2. WebAssembly: sql.js

v0.18 Feb 2019 - Medea as Backend

Powered by Medea

DEPRECATED: Due to #79 #74 and also it is very unstable in production as my experiences. (e.g. memory leak & block event loop)

  1. Switch from SnapDB to MedeaDown

Medea is a persistent key-value storage library that runs everywhere Node runs.

"It is a pure JS implementation of leveldown and it's almost as fast." — @Raynos link

"The LevelDOWN-compatible wrapper for Medea really opens up the possibility to reuse the modules that have already been created around the LevelUP ecosystem." — @kevinswiber link

Known Issues: FlashStore 会写满磁盘的问题 #155

async function compact (store: FlashStore): Promise<void> {
  await store.size
  const db = (store as any).levelDb.db.db.db
  await new Promise((resolve, reject) => {
    db.compact((err: any) => {
      if (err) {
        return reject(err)
      }
      resolve()
    })
  })
}

v0.16 May 2019 - SnapDB as Backend

Powered by SnapDB

  1. Switch from RocksDB to SnapDB #45
  2. #50 has been fixed. WARN: Do not use this version because it has known issues

v0.14 May 2019 - RocksDB as Backend

  1. Switch from LevelDB to RocksDB #34

v0.12 Jan 2019 - LevelDB as Backend

  1. Use LevelDB as backend to skip the compiling when install.
  2. Using leveldb official typings from @types/

v0.7 Aug 2018 - Nosql-LevelDB as Backend

  1. Use nosql-leveldb as backend to prevent segfault.

v0.6 Jul 2018

  1. Upgrade to TypeScript 3.0

v0.4 Jun 2018

1. Refactor API to implement 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.

FAQ

Q: What's the difference between the flash-store and memory-card

Short answer:

  1. flash-store is for save data to local filesystem.
  2. memory-card is for save data to a distributed network storage, it can be serialized/deserialized safely with the minimum payload transfered 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 cache from other API.

memory-card is using a local file to store data in JSON format by default, however, it supports more distributed methods and it can be serialized/deserialized safely with the minimum payload for transfer the data between networks (for example, it can serialize itself to only include the redis config and then deserialize it to restore a MemoryCard instance with the same data backend). Learn more from it's repository at here

Author

Huan LI (李卓桓) [email protected]

Profile of Huan LI (李卓桓) on StackOverflow

  • Code & Docs © 2017-now Huan (李卓桓) <[email protected]>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

flash-store's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar huan avatar lijiarui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flash-store's Issues

Question about `flockSync()`

In the constructor of FlashStore, I have some questions about these code:

    this.lockFd = fs.openSync(lockFile, 'w')
    try {
      flockSync(this.lockFd, 'exnb')
    } catch (e) {
      log.error('FlashStore', 'constructor() wEorkdir("%s") is busy: maybe there another FlashStore are using it?', this.workdir)
      throw e
    }

I found that if we call wechaty.reset() some Errors will happened, and then we can not use cache any more.

If we change the params exnb to shnb in method flockSync(this.lockFd, 'exnb') , it would make cache work in the next start.

But I'm not sure it would make some other bugs or not.

Little confused about FlashStore.size

In FlashStore, set value to the same key more than one time will make the size wrong, but no Error.

If we set the same key more than one time

await flashStore.set('name', '1')
await flashStore.set('name', '2')
await flashStore.set('name', '3')
const size = await flashStore.size // size: 3

and then let's restart the script again, size: 4.

If execute this script only

const size = await flashStore.size // size: 1, right!

I'm confused with this case.

BTW, Im trying to find out the reason about Issue: wechaty/wechaty-puppet-padpro#191

Can not get data success

flash-store version: v0.18.14

I can not provided the exact reproduce step for this problem. And Im not sure this problem is related compactDB() method or not.

It occurs in these cases:

  • large storage
  • get or set frequently

Log

ReadError: Unexpected end of JSON input
    at /xiaoju-bot/node_modules/levelup/lib/levelup.js:194:15
    at /xiaoju-bot/node_modules/encoding-down/index.js:79:14
    at /xiaoju-bot/node_modules/medeadown/medeadown.js:129:7
    at /xiaoju-bot/node_modules/medea/medea.js:551:15
    at FSReqWrap.wrapper [as oncomplete] (fs.js:463:17)

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.9.2 to 1.9.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v1.9.3

2019-04-10

Bug Fixes

  • Simplify return expressions that are evaluated before the surrounding function is bound (#2803)

Pull Requests

  • #2803: Handle out-of-order binding of identifiers to improve tree-shaking (@lukastaegert)
Commits

The new version differs by 3 commits.

  • 516a06d 1.9.3
  • a5526ea Update changelog
  • c3d73ff Handle out-of-order binding of identifiers to improve tree-shaking (#2803)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

falshStore.value() cannot work as expect

in flashStore.values, {lte: 10} result is 3, while {gte: 10} result is 5

snip as follows:

import { FlashStore } from '../src/flash-store'
async function main() {
  const flashStore = new FlashStore('falshstore.workdir')

  console.log('all values')
  for await (const value of flashStore.values()) {
    console.log(value)
  }

  console.log('value gte 10')
  for await (const value of flashStore.values({gte: 10})) {
    console.log(value)
  }

  console.log('value lte 10')
  for await (const value of flashStore.values({lte: 10})) {
    console.log(value)
  }

}
main()

output as follows:

all values
3
5
value gte 10
5
value lte 10
3

Fork "github:MeirionHughes/levelup"

I'm going to start a new round of cleaning up the typings on level*, if you're dependent on my fork, I recommend you fork from me to save it.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 12.12.1 to 12.12.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet.
We recommend using:

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

An in-range update of snap-db is breaking the build 🚨

The dependency snap-db was updated from 1.1.5 to 1.1.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

snap-db is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • Travis CI - Pull Request: The build errored. This is a change from the previous build, which canceled.

Commits

The new version differs by 5 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

How to mute the flash-store log, it's really verbose indeed.

The default log level is verbose, if we set brolog level as verbose, it would also effect flash-store.

We want to mute the flash-store log.

17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO PuppetWhatsApp room roomMemberList([email protected])
17:18:01 VERB FlashStore get([email protected])
17:18:01 INFO BotAction syncRoom() room list from wechaty has 36 in total.
17:18:01 INFO BotAction syncRoom() room list from db has 36 in total.
17:18:01 INFO BotAction syncRoom() room list from add has 0 in total.
17:19:02 VERB ConfigManager receive maintain mode heartbeat.
17:19:23 INFO BotAction syncContact(ready=false, forceSync=false)
17:19:23 VERB Contact findAll()
17:19:23 VERB Puppet contactSearch(query=undefined, )
17:19:23 INFO PuppetWhatsApp contact contactList()
17:19:23 VERB FlashStore keys()
17:19:23 VERB FlashStore *entries({})
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])
17:19:23 VERB FlashStore get([email protected])

Throw error when running, currently not sure what's the reproduce steps

(node:9) UnhandledPromiseRejectionWarning: ReadError: Unexpected end of JSON input
    at /xiaoju-bot/node_modules/levelup/lib/levelup.js:194:15
    at /xiaoju-bot/node_modules/encoding-down/index.js:79:14
    at /xiaoju-bot/node_modules/medeadown/medeadown.js:129:7
    at /xiaoju-bot/node_modules/medea/medea.js:551:15
    at FSReqWrap.wrapper [as oncomplete] (fs.js:463:17)
(node:9) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 518)

Code in the levelup.js

LevelUP.prototype.get = function (key, options, callback) {
  if (key === null || key === undefined) {
    throw new ReadError('get() requires a key argument')
  }

  var promise

  callback = getCallback(options, callback)

  if (!callback) {
    callback = promisify()
    promise = callback.promise
  }

  if (maybeError(this, callback)) { return promise }

  options = getOptions(options)

  this.db.get(key, options, function (err, value) {
    if (err) {
      if ((/notfound/i).test(err) || err.notFound) {
        err = new NotFoundError('Key not found in database [' + key + ']', err)
      } else {
        err = new ReadError(err)
      }
      return callback(err)
    }
    callback(null, value)
  })

  return promise
}

When called the db.get(), it throws the error.

Open this issue for recording the error stack, currently I don't know how to reproduce this issue since the error stack is too short.

Switch to SnapDB

SnapDb is a Simple & Robust LSM Powered Javascript key-value store with Zero dependencies with pure JavaScript implementation.

Switch to SnapDB will solve #43 and make the installation easy for the end-users who have no build tool installed.

v0.14 breaks wechaty-puppet-padpro

When it init the store, some logs printed in the console then process exited.

L0 files seqno 1553 1598 vs. 72057594037927935 0
L0 files seqno 1146 1178 vs. 72057594037927935 0
zsh: abort      PADPRO_LOG=silly ts-node test.ts

Code that cause the issue:

    const baseDir = path.join(
      os.homedir(),
      path.sep,
      '.wechaty',
      'puppet-padpro-cache',
      path.sep,
      token,
      path.sep,
      userId,
    )

    const baseDirExist = await fs.pathExists(baseDir)

    if (!baseDirExist) {
      await fs.mkdirp(baseDir)
    }

    this.cacheContactRawPayload        = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
    this.cacheRoomMemberRawPayload     = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
    this.cacheRoomRawPayload           = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))
    this.cacheRoomInvitationRawPayload = new FlashStoreSync(path.join(baseDir, 'room-invitation-raw-payload'))
    this.cacheFile                     = new FlashStoreSync(path.join(baseDir, 'file-cache'))

    await Promise.all([
      this.cacheContactRawPayload.ready(),
      this.cacheRoomMemberRawPayload.ready(),
      this.cacheRoomRawPayload.ready(),
      this.cacheRoomInvitationRawPayload.ready(),
      this.cacheFile.ready(),
    ])

    const roomMemberTotal = [...this.cacheRoomMemberRawPayload.values()].reduce(
      (acc, cur) => acc + Object.keys(cur).length, 0
    )

    const contactTotal = this.cacheContactRawPayload.size
    const roomTotal = this.cacheRoomRawPayload.size

Is there anything that I did is wrong here? Or is there anything that I can do to collect more info for you? @huan

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 13.5.1 to 13.5.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Installing flash-store v0.12.1 in alpine throws errors: no linux/fs.h

I got errors when building docker images with base container node:10.15.0-alpine, here is the error message:

../deps/leveldb/leveldb-rocksdb/util/io_posix.cc:16:22: fatal error: linux/fs.h: No such file or directory
 #include <linux/fs.h>
                      ^
compilation terminated.
make: *** [deps/leveldb/leveldb.target.mk:299: Release/obj.target/leveldb/deps/leveldb/leveldb-rocksdb/util/io_posix.o] Error 1

Searched with google, found that the file is in the linux-headers package.

So add apk add linux-headers into the docker build file, everything works like a charm.

This issue is to record the problems that I encountered and how I solve it, so people who met the same problem could solve it easily.

Can not use `import levelup from 'levelup'`, cause rollup fail.

Rollup complains that:

> [email protected] rollup /home/zixia/git/flash-store
> rollup -c

dist/flash-store.js → bundles/flash-store.es6.umd.js...
[!] Error: Cannot call a namespace ('encoding')
dist/flash-store.js (41:24)
39:         log.verbose('FlashStore', 'constructor()');
40:         // https://twitter.com/juliangruber/status/908688876381892608
41:         const encoded = encoding(leveldown(workDir));
                            ^
42:         this.levelDb = levelup(encoded);
43:         this.levelDb.setMaxListeners(17); // default is Infinity

Had sent PR to levelup: Level/levelup#494

See Also: rollup/rollup#1267 (comment)

An in-range update of ts-node is breaking the build 🚨

The devDependency ts-node was updated from 8.4.0 to 8.4.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ts-node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • Travis CI - Pull Request: The build errored. This is a change from the previous build, which canceled.

Release Notes for Fix 8.20 dependency regression

Fixed

  • Revert "List all files in memory cache improves perf 1.4x" 87a6e2c
Commits

The new version differs by 2 commits.

  • 32bf911 8.4.1
  • 87a6e2c Revert "List all files in memory cache improves perf 1.4x"

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Get the total number (`size`) of the LevelDB keys

Current we are using a for loop to loop all keys to count:

public get size (): Promise<number> {
log.verbose('FlashStore', 'size()')
/* eslint no-async-promise-executor: 0 */
// TODO: is there a better way to count all items from the db?
return new Promise<number>(async (resolve, reject) => {
try {
let count = 0
for await (const _ of this) {
count++
}

Related links:

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 10.11.0 to 10.11.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • Travis CI - Branch: The build failed.

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Switch from SnapDB to MedeaDown on [email protected]

Medea is a persistent key-value storage library that runs everywhere Node runs.

"It is a pure JS implementation of leveldown and it's almost as fast."
@Raynos link

"The LevelDOWN-compatible wrapper for Medea really opens up the possibility to reuse the modules that have already been created around the LevelUP ecosystem."
@kevinswiber link

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.27.6 to 1.27.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v1.27.7

2019-12-01

Bug Fixes

  • Fix a scenario where a reassignments to computed properties were not tracked (#3267)

Pull Requests

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of tstest is breaking the build 🚨

The devDependency tstest was updated from 0.4.5 to 0.4.9.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tstest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • Travis CI - Pull Request: The build errored. This is a change from the previous build, which canceled.

Commits

The new version differs by 8 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

`compress` option for FlashStoreAsync

As we are caching all the data in memory from FlashStoreSync, the memory will be required a lot if we need to store huge data.

If the data is not read/write very frequency, it's a good idea to compress the data so that we can save memory.

Plan to add a { compress: false/true } option to FlashStoreSync to enable in-memory data compress.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.