upring-kv
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 = logLevel: 'info' base: hashring: joinTimeout: 200 replicaPoints: 10 upring upring { upringkv} { if err return upringlogger upringkv} { if err return upringlogger console upring}
API
kv.get(key, cb(err, value))
Get a value from the hashring.
async-await is supported as well:
await upringkv
kv.put(key, value, cb(err))
Put value
in the hashring for the given key.
async-await is supported as well:
await upringkv
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