-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
defined commands don't work the first time within multi #104
Comments
Seems to work fine with pipeline enabled. Work-around that works for meI only disabled pipeline because I don't know ahead of time the commands I'll be sending in the multi block. So I can't chain them. For my purposes, rather than disabling pipeline, I can just build an array of commands and submit them as a batch to the multi constructor. redis.defineCommand('echoDynamicKeyNumber', {
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
var commands = [];
commands.push(['echoDynamicKeyNumber', 2, 'k1', 'k2', 'a1', 'a2']);
if (somethingExists) {
commands.push(['conditionalCommand', 'arg1', 'arg2']);
}
...
redis.multi(commands).exec(function(){..}); |
Hi, redis.multi({ pipeline: false });
redis.set('foo', 'bar');
redis.get('foo');
redis.echoDynamicKeyNumber(2, 'k1', 'k2', 'a1', 'a2');
redis.exec(); Would actually sending commands to Redis server as the following order:
Since pipelining in ioredis is very flexible, you can use pipelining this way: var pipeline = redis.multi().echoDynamicKeyNumber(2, 'k1', 'k2', 'a1', 'a2');
if (condition) {
pipeline.get('foo');
}
pipeline.exec(); |
@luin thanks! That'll work for me. You can close this if you'd like. |
Looks like defined commands cannot be run for the first time inside of a multi block.
Produces:
NOSCRIPT No matching script. Please use EVAL.
Is this intended or necessary behaviour? Seems like there are tests for pipeline, but not multi with no pipeline.
If I load a lua file with defineCommand, and execute the command at least once before the multi block, it works.
The text was updated successfully, but these errors were encountered: