Transaction
여러 명령어들을 원자성있게 실행하도록 보장하는 방법
개념
트랜잭션 활용법
MULTI
> MULTI
OK
> INCR foo
QUEUED
> INCR bar
QUEUED
> EXEC
1) (integer) 1
2) (integer) 1WATCH
Spring Data Redis에서 트랜잭션 사용하기
Last updated
여러 명령어들을 원자성있게 실행하도록 보장하는 방법
> MULTI
OK
> INCR foo
QUEUED
> INCR bar
QUEUED
> EXEC
1) (integer) 1
2) (integer) 1Last updated
WATCH mykey
val = GET mykey
val = val + 1 // 값 변경
MULTI
SET mykey $val
EXEC//execute a transaction
List<Object> txResults = redisTemplate.execute(new SessionCallback<List<Object>>() {
public List<Object> execute(RedisOperations operations) throws DataAccessException {
operations.multi();
operations.opsForSet().add("key", "value1");
// This will contain the results of all operations in the transaction
return operations.exec();
}
});