1.0.0 • Published 11 years ago

fs-key-value v1.0.0

Weekly downloads
14
License
-
Repository
github
Last release
11 years ago

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()
}
1.0.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago