Socket
Socket
Sign inDemoInstall

cluster-memdb

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cluster-memdb

key-value memory database for single process application and cluster application


Version published
Maintainers
1
Install size
14.5 kB
Created

Readme

Source

cluster-memdb

A key-value memory database for single process application and cluster application.

Using this util, you can share datas in every processes of cluster.

installation

npm install cluster-memdb

usage

this example show you how to use it, you can read .d.ts for more information

import {memdb, dbs} from 'cluster-memdb'

// declare database (won't create any keys)
const userdb = memdb('user', 'id')
const lovedb = memdb('love', 'key')

// create "user" key and write those 2 users to "user"
await userdb.save([
    {id:1, name:'Mike', gender:'male', love:['bread']},
    {id:2, name:'Louis', gender:'female', love:['beef', 'bread']},
])

// clean "love" key and write new datas
await lovedb.replace([
    {key:'bread', price:'3.00'},
    {key:'beef', price:'10.00'}
])

await dbs()    // ["user", "love"]

await userdb.getAll()    // [{id:1, ...}, {id:2, ...}]

await lovedb.getByKeys(['bread'])    // [{key:'bread', price:'3.00'}]

await userdb.find({name:'Mike'})    // [{id:1, ...}]

// "Mike" and "Louis" both deleted
await userdb.delete([1, 2])

// "bread" and "beef" both deleted
await love.clean()

Keywords

FAQs

Last updated on 30 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc