ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## watch, unwatch ##### Description Watches a key for modifications by another client. If the key is modified between `<span class="calibre12">WATCH</span>` and `<span class="calibre12">EXEC</span>`, the MULTI/EXEC transaction will fail (return `<span class="calibre12">FALSE</span>`). `<span class="calibre12">unwatch</span>` cancels all the watching of all keys by this client. 监控一个KEY是否被其他的客户端修改。如果KEY在调用watch()和exec()之间被修改,那么批量处理最终的exec()执行将失败。unwatch()取消对于所有KEY值的监控操作针对于这个Redis实例。通过一些实验,这个函数的效果其实并没有那么好,或者说不能够准确的去监控。 ##### Parameters *keys*: a list of keys ##### Example ``` <pre class="calibre9">$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. */ ```