MULTI/EXEC result inside PIPELINE
When I use multi/exec inside a pipe and some watched key was changed, I'm getting an empty array instead of false.
$redis->watch('x'); $redis1->set('x',1); $pipe=$redis->multi(Redis::PIPELINE); $pipe->multi(); $pipe->exec(); var_dump($pipe->exec()[0]);
Expected behaviour
bool(false)
Actual behaviour
array(0) { }
I think the output should be the same as: $redis->watch('x'); $redis1->set('x',1); $redis->multi(); var_dump($redis->exec());
Because otherwise there's no way to check if watched key changed or not.
I'm seeing this behaviour on
- OS: Ubuntu 16.04
- Redis: 4.0.11
- PHP: PHP 7.0.30-0ubuntu0.16.04.1
- phpredis: 4.1.1
I've checked README and it states: If the key is modified between WATCH and EXEC, the MULTI/EXEC transaction will fail (return FALSE).
So, exec() should return boolean false (even using pipeline). It is very useful if there are no commands in the transaction but you need to know if watched keys changed or not.
I think we can tackle this for PhpRedis 7.0. Even though it's a bit wonky now i don't think we can change it before that due to BC.