Skip to content

client.batch is not a function #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jurrienk opened this issue Dec 22, 2021 · 1 comment
Open

client.batch is not a function #1796

jurrienk opened this issue Dec 22, 2021 · 1 comment

Comments

@jurrienk
Copy link

When updating from v3->v4 I can no longer use the batch() function on the redisClient object.

The migration guide makes no reference of this being unsupported.

setting legacyMode to true does not resolve this.

Environment:

  • Node.js Version: v14" -->
  • Node Redis Version: 4.0.1
@jurrienk jurrienk added the Bug label Dec 22, 2021
@leibale
Copy link
Contributor

leibale commented Dec 27, 2021

We definitely need to add it to the migration guide and changelog (I'll leave this issue open until we'll do it), but:

  1. As described here, commands from the same "event loop tick" are "batched" anyway.
  2. In case you use .batch as a way to queue commands and execute them later, you can do:
const [getReply, setReply] = await client.multi()
  .get('1')
  .set('2', '2')
  .execAsPipeline();

// you can "save" a "multi" instance and use it later
const multi = client.multi();
process.on('message', message => {
  if (message === 'EXEC') {
    return multi.execAsPipeline();
  }

  multi.sAdd('messages', message);
});

@leibale leibale added Documentation and removed Bug labels Dec 27, 2021
poppinlp pushed a commit to poppinlp/node_redis-vs-ioredis that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants