0.5.0 • Published 6 years ago

upring-kv v0.5.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

upring-kv

npm version Build Status js-standard-style Coverage Status

Key Value store plugin for UpRing.

Install

npm i upring-kv --save

Usage

This library exposes the standard upring plugin interface.
Once you register it, it adds a kv name space with the API documented below.

const upring = require('upring')({
  logLevel: 'info',
  base: [],
  hashring: {
    joinTimeout: 200,
    replicaPoints: 10
  }
})

upring.use(require('upring-kv'))

upring.on('up', onReady)

function onReady () {
  upring.kv.put('hello', 'world', onPut)
}

function onPut (err) {
  if (err) {
    return upring.logger.error(err)
  }
  upring.kv.get('hello', onGet)
}

function onGet (err, value) {
  if (err) {
    return upring.logger.error(err)
  }
  console.log(value)
  upring.close()
}

API

  • kv#get()
  • kv#put()
  • kv#liveUpdates()

kv.get(key, cb(err, value))

Get a value from the hashring.
async-await is supported as well:

await upring.kv.get('key')

kv.put(key, value, cb(err))

Put value in the hashring for the given key. async-await is supported as well:

await upring.kv.put('key', 'value')

kv.liveUpdates(key)

Returns a Readable stream in objectMode, which will include all updates of given key. It will emit the last value that was put, and it will re-emit it when reconnecting between multiple hosts.

Acknowledgements

This project is kindly sponsored by nearForm.

License

MIT

0.5.0

6 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago