watch 命令/方法/函数

Description

Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, the MULTI/EXEC transaction will fail (return FALSE).

监控一个KEY是否被其他的客户端修改。如果KEY在调用watch()和exec()之间被修改,那么批量处理最终的exec()执行将失败。通过一些实验,这个函数的效果其实并没有那么好,或者说不能够准确的去监控。


Parameters

keys: a list of keys


Example

$redis->watch('x');

/* long code here during the execution of which other clients could well modify `x` */

$ret = $redis->multi()

    ->incr('x')

    ->exec();

/*

$ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.

*/