Redis functions
wrap redis node.js driver expose command function and parse returned if json command specific
npm i @zaeny/redis
parsing json data automaticly, both input json and output json
process.env.REDIS_URL="redis://redisuser:redispass@127.0.0.1:6379"
var client = createRedis(process.env.REDIS_URL);
connectRedis(client)
.then(()=> console.log('redis connected'));
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();
createRedis,
connectRedis,
command,
reader,
parsePair,
- Composable - Collection of functions to solve programming problem
- [1.0.0] add
command
and basic parsing json - [1.0.1] add blocking
reader
to support basicxread
andxreadgroup
- [1.0.2] add
parsePair
parsing tupple return from redis into object js - [1.0.3] fix
parsePair
isEven
is not defined - [1.0.4] add
retry_strategy
reconnecting, addtfload
,tfcall
- [1.0.5] fix json.get return array