New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

fs-key-value

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-key-value

Key value data store using the filesystem

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
14
100%
Maintainers
1
Weekly downloads
 
Created
Source

fs-key-value

This module provides a simple key value data store using only the file system. It makes use of file locking to allow safe operation in a multiple process environment without the overhead of a separate database server.

Installation

$ npm install fs-key-value

Example

var FsKeyValue = new require('fs-key-value')

var db = new FsKeyValue('./mydb')

var cluster = require('cluster')

if (cluster.isMaster) {
  for (var i = 0; i < 8; i++) {
    cluster.fork()
  }
} else {
  var id = cluster.worker.id % 2

  db.put('hoopla' + id, {'msg': 'ballyhoo ' + cluster.worker.id})

  var data = db.get('hoopla' + id)
  if (data != undefined) {
    console.log(data.msg)
  }

  db.del('hoopla' + id)

  cluster.worker.kill()
}

Keywords

key

FAQs

Package last updated on 16 Aug 2013

Related posts