라이브러리

[PHP] MongoDBDriverSession::getTransactionOptions - 현재 실행 중인 트랜잭션에 대한 옵션을 반환합니다.




MongoDBDriverSession::getTransactionOptions

`MongoDBDriverSession::getTransactionOptions` 메서드는 MongoDB 드라이버의 세션에 대한 트랜잭션 옵션을 반환합니다. 트랜잭션 옵션은 MongoDB에서 트랜잭션을 수행할 때 사용하는 옵션을 지정합니다.

트랜잭션 옵션


트랜잭션 옵션은 다음을 포함합니다.

* `readConcern`: 읽기 우선 순위
* `writeConcern`: 쓰기 우선 순위
* `readPreference`: 읽기 선호도
* `maxTimeMS`: 최대 실행 시간
* `retryReads`: 읽기 재시도
* `retryWrites`: 쓰기 재시도

예제


#hostingforum.kr
php

use MongoDBDriverSession;

use MongoDBDriverOptions;



// MongoDB 드라이버 세션 생성

$sess = new Session();



// 트랜잭션 옵션 설정

$options = $sess->getTransactionOptions();



// 읽기 우선 순위 설정 (강제 읽기)

$options->readConcern = 'majority';



// 쓰기 우선 순위 설정 (강제 쓰기)

$options->writeConcern = 'majority';



// 읽기 선호도 설정 (nearest)

$options->readPreference = 'nearest';



// 최대 실행 시간 설정 (10초)

$options->maxTimeMS = 10000;



// 읽기 재시도 설정 (true)

$options->retryReads = true;



// 쓰기 재시도 설정 (true)

$options->retryWrites = true;



// 트랜잭션 옵션 출력

print_r($options);



결과


#hostingforum.kr
php

MongoDBDriverOptions Object

(

    [readConcern] => MongoDBDriverReadConcern Object

        (

            [level] => majority

        )



    [writeConcern] => MongoDBDriverWriteConcern Object

        (

            [w] => majority

        )



    [readPreference] => MongoDBDriverReadPreference Object

        (

            [mode] => nearest

        )



    [maxTimeMS] => 10000

    [retryReads] => 1

    [retryWrites] => 1

)



참고


* `MongoDBDriverSession` 클래스는 MongoDB 드라이버의 세션을 관리합니다.
* `MongoDBDriverOptions` 클래스는 트랜잭션 옵션을 관리합니다.
* `readConcern`, `writeConcern`, `readPreference`, `maxTimeMS`, `retryReads`, `retryWrites`는 트랜잭션 옵션의 기본값입니다.
* `getTransactionOptions` 메서드는 트랜잭션 옵션을 반환합니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 388 페이지

검색

게시물 검색