
MongoDBDriverSession::getTransactionOptions 메서드는 트랜잭션 옵션을 설정하기 위해 사용됩니다. 이 메서드는 TransactionOptions 객체를 반환합니다.
TransactionOptions 객체는 여러 옵션을 설정할 수 있습니다.
- readConcern: 읽기 우선순위 옵션입니다. 예를 들어, LOCAL, MAJORITY, LINEARIZABLE, AVAILABLE 등이 있습니다.
- writeConcern: 쓰기 우선순위 옵션입니다. 예를 들어, ACKNOWLEDGED, W1, W2, W3 등이 있습니다.
- isolationLevel: 격리 수준 옵션입니다. 예를 들어, SNAPSHOT, RE repeatableRead, READ_COMMITTED 등이 있습니다.
이러한 옵션을 설정하는 예제는 다음과 같습니다.
#hostingforum.kr
php
$session = new MongoDBDriverSession();
$transactionOptions = $session->getTransactionOptions();
$transactionOptions->setReadConcern(MongoDBDriverReadConcern::LOCAL);
$transactionOptions->setWriteConcern(MongoDBDriverWriteConcern::ACKNOWLEDGED);
$transactionOptions->setIsolationLevel(MongoDBDriverIsolationLevel::SNAPSHOT);
// 트랜잭션 옵션을 설정한 후에 트랜잭션을 시작할 수 있습니다.
몽고 DB 드라이버의 트랜잭션 옵션을 설정할 때 참고할 수 있는 공식 문서는 다음과 같습니다.
- MongoDB Driver Manual: Transactions
- MongoDB Driver Manual: Transaction Options
이 문서를 참고하여 올바르게 트랜잭션 옵션을 설정할 수 있습니다.
2025-04-19 03:30