1.1.12 • Published 9 months ago
@zaeny/redis v1.1.12
@zaeny/redis
Redis functions
wrap redis node.js driver expose command function and parse returned if json command specific
Getting Started
npm i @zaeny/redis
Usage
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)
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
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
- 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
command
in cluster mode, supportisReadonly
command - 1.1.7 add simple replication routing, use weight distribution
- 1.1.8 add fix for duplicate client for
reader
command - 1.1.9 add support for sending string
command
- 1.1.10 add
zpopmin
as write commands - 1.1.11 add
zpopmax
,eval
,evalsha
,function
to write commands - 1.1.12 add
forceMode
read
orwrite
in replication command
1.1.12
9 months ago
1.1.11
9 months ago
1.1.10
9 months ago
1.1.9
10 months ago
1.1.8
10 months ago
1.1.7
10 months ago
1.1.6
10 months ago
1.1.5
10 months ago
1.1.4
11 months ago
1.1.3
12 months ago
1.0.7
12 months ago
1.1.2
12 months ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago