redis icon indicating copy to clipboard operation
redis copied to clipboard

Ability to use xread and pipeline/tx in parallel

Open zifeo opened this issue 2 years ago • 1 comments

This seems to only be a restriction/issue? with pipeline/tx, simple commands seem to work. Currently ends up in multiple errors: Invalid state, -ERR Protocol error: invalid multibulk length, raw.split is not a function or its return value is not iterable and similar.

const client = await newClient(opts);

// async
client.xread([{ key: "test", xid: 0 }], { block: 5000 });

const tx = client.pipeline();
tx.xadd("test", "*", {a: "a"}, { approx: true, elements: 10000 });
const resp = await tx.flush();

client.close();

zifeo avatar Apr 27 '22 00:04 zifeo

Note that simple commands will be delayed and cannot happen in parallel of xread "blocks". The workaround is to use two connections and might be worth clarifying in the documentation.

zifeo avatar May 28 '22 14:05 zifeo