@zaeny/redis

1.0.5 • Public • Published

@zaeny/redis

npm version npm downloads

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)
  .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();

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 basic xread and xreadgroup
  • [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, add tfload, tfcall
  • [1.0.5] fix json.get return array

Readme

Keywords

Package Sidebar

Install

npm i @zaeny/redis

Weekly Downloads

40

Version

1.0.5

License

ISC

Unpacked Size

10.8 kB

Total Files

3

Last publish

Collaborators

  • azizzaeny