Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of using Redis Streams with Javascript/ioredis
var Redis = require('ioredis');
var redis = new Redis({
host: "",
password: "7884b8baaa49fbcb48f17ad2a146"
async function main() {
// write an event to stream 'events', setting 'key1' to 'value1'
await redis.sendCommand(
new Redis.Command("XADD", ["queue", "*", "message", "NodeJS"]));
// read events from the beginning of stream 'events'
let res = await redis.sendCommand(
new Redis.Command("XREAD", ["STREAMS", "queue", 0]));
// parse the results (which are returned in quite a nested format)
let events = res[0][1];
for (var i=0; i<events.length; i++) {
let thisEvent = events[i]
console.log("## id is ", thisEvent[0].toString());
for (var eachKey in thisEvent[1]) {

This comment has been minimized.

Copy link

@cngeru cngeru commented Jul 30, 2020

Any way to use it with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.