denodrivers / redis

🦕 Redis client for Deno 🍕
https://deno.land/x/redis
MIT License
453 stars 45 forks source link

Ability to use xread and pipeline/tx in parallel #304

Open zifeo opened 2 years ago

zifeo commented 2 years ago

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 commented 2 years ago

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.