Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cluster-memdb

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-memdb

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

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 30 Nov 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc