这种模式合法吗?
$redis->watch('foo');
$var1 = $redis->get('foo');
$redis->watch('bar');
$var2 = $redis->get('bar');
$redis->multi();
$redis->mset(['foo' => 42, 'bar' => 9001]);
$redis->exec();
或者秒看调用取消了先看状态?
最佳答案
这个模式是合法的。来自 redis documentation
WATCH can be called multiple times. Simply all the WATCH calls will have the effects to watch for changes starting from the call, up to the moment EXEC is called. You can also send any number of keys to a single WATCH call.
关于transactions - Redis 中的顺序监视调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20115281/