UNPKG

@house-agency/brewstore

Version:
50 lines (44 loc) 1.2 kB
keyvalue ======== ::javascript // Setup key/value storage with automatic connection // with connection properties stored in configuration // file. const conf = require('@house-agency/brewtils/config').load('config.json'); const keyvalue = require('brewstore/keyvalue'); // Configuration properties looks like this { "storage": { "keyvalue": { "host": "localhost", "port": "6379", "db": 0 } } } // Send commands and get results like this keyvalue.run('some-key', 'set', 'some-value') .then(() => { return keyvalue.run('some-key', 'get'); }) .then(results => { // results === some-value }); // Listen on some channel keyvalue.listen('some-channel') .then(listener => { // Listener comes as a rx observable listener.subscribe( message => { // message }, error => { // error } ); ); // Get a new client, for some reason... keyvalue.get_client() .then(client => { // Your new client });