transactions - Redis 中的顺序监视调用

标签 transactions redis optimistic-locking

这种模式合法吗?

$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/

相关文章:

java - 在 Spring/Hibernate 环境中手动管理数据库事务

database - 电子邮件数据库架构

redis "10000 changes in 60 seconds"每 3 分钟运行一次

PHP/MySQL/jQuery 记录的悲观锁

sql - 具有 "version"字段的乐观锁与快照隔离级别

java - Spring @Controller 和 Transactionmanager

Java 和 MySQL 事务

postgresql - PostgreSQL 中的事后死锁调试

ruby-on-rails - Redis future + rails

java - jQGrid 编辑中的行锁定