@zaeny/redis
v1.1.12
Published
Utility functions wrap redis node.js driver
Downloads
64
Readme
@zaeny/redis
Redis functions
wrap redis node.js driver expose command function and parse returned if json command specific
Getting Started
npm i @zaeny/redisUsage
parsing json data automaticly, both input json and output json
process.env.REDIS_URL="redis://redisuser:[email protected]:6379"
var client = createRedis(process.env.REDIS_URL);
connectRedis(client)
command(['ping'], client).then(console.log)
command(['json.get', 'foo', '$.data'], client)
command(['json.set', 'foo', '$', {data: 1}], client)
command(['json.mget', 'foo', 'bar', '$'], client)blocking read and stream reading
reader(['xreadgroup', 'mystream', 'group1', 'consumer1', '100', '0', '0'], (data)=> console.log(data), rs);
reader(['xread', 'mystream', '100', '0', '0'], (data)=> console.log(data), rs);
command(['xadd', 'mystream', {data: '1'}], rs)
command(['xadd', 'mystream', ['data', '1']], rs); closing stream
var mystream = reader(['xread', 'mystream', '100', '0', '0'], (data)=> console.log(data), rs);
mystream.close();add acknowledge
// ack([streamId]);
var processStream = ((data, ack) =>{
ack(map(first, data));
console.log(data);
}
reader(['xreadgroup', 'mystream', 'group1', 'consumer1', '100', '0', '0'], processStream, rs);var mystream = reader(['xread', 'mystream', '100', '0', '0'], (data)=> console.log(data), rs);
API
createRedis,
connectRedis,
command,
reader,
parsePair,Related work
- Composable - Collection of functions to solve programming problem
Changes
- [1.0.0] add
commandand basic parsing json - [1.0.1] add blocking
readerto support basicxreadandxreadgroup - [1.0.2] add
parsePairparsing tupple return from redis into object js - [1.0.3] fix
parsePairisEvenis not defined - [1.0.4] add
retry_strategyreconnecting, addtfload,tfcall - [1.0.5] fix json.get return array
- [1.0.6] fix multiple path
$.[]at json.get - [1.0.7] move to new repositoy, add
xack - [1.1.2] add new stream acknowledge
- [1.1.3] fix repository homepage
- [1.1.4] fix the parse value for
json.mget - [1.1.5] add
createClusterRedis - [1.1.6] add support
commandin cluster mode, supportisReadonlycommand - [1.1.7] add simple replication routing, use weight distribution
- [1.1.8] add fix for duplicate client for
readercommand - [1.1.9] add support for sending string
command - [1.1.10] add
zpopminas write commands - [1.1.11] add
zpopmax,eval,evalsha,functionto write commands - [1.1.12] add
forceModereadorwritein replication command
