Key Value store plugin for UpRing.
npm i upring-kv --save
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()
}
Get a value from the hashring.
async-await is supported as well:
await upring.kv.get('key')
Put value
in the hashring for the given key.
async-await is supported as well:
await upring.kv.put('key', 'value')
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.
This project is kindly sponsored by nearForm.
MIT