Couchbase Collection Cache Adapter

This adapter stores the values in-memory using one (or more) Couchbase server instances. Unlike the APCu adapter, and similarly to the Memcached adapter, it is not limited to the current server's shared memory; you can store contents independent of your PHP environment. The ability to utilize a cluster of servers to provide redundancy and/or fail-over is also available.

このアダプターは、1 つ (または複数) の Couchbase サーバーインスタンスを使用してメモリ内に値を保存します。 APCu アダプタとは異なり、Memcached アダプタと同様に、現在のサーバーの共有メモリに限定されません。 PHP 環境から独立してコンテンツを保存できます。サーバーのクラスターを利用して、冗長性やフェイルオーバーを提供する機能も利用できます。

Caution

注意

Requirements: The Couchbase PHP extension as well as a Couchbase server must be installed, active, and running to use this adapter. Version 3.0 or greater of the Couchbase PHP extension is required for this adapter.

要件: このアダプターを使用するには、Couchbase PHP 拡張機能と Couchbase サーバーがインストールされ、アクティブで、実行されている必要があります。このアダプターには、バージョン 3.0 以上の Couchbase PHP 拡張機能が必要です。

This adapter expects a Couchbase Collection instance to be passed as the first parameter. A namespace and default cache lifetime can optionally be passed as the second and third parameters:

このアダプターは、Couchbase Collection インスタンスが最初のパラメーターとして渡されることを想定しています。名前空間とデフォルトのキャッシュの有効期間は、必要に応じて 2 番目と 3 番目のパラメーターとして渡すことができます。
1
2
3
4
5
6
7
8
9
10
11
12
13
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;

$cache = new CouchbaseCollectionAdapter(
    // the client object that sets options and adds the server instance(s)
    $client,

    // a string prefixed to the keys of the items stored in this cache
    $namespace,

    // the default lifetime (in seconds) for cache items that do not define their
    // own lifetime, with a value 0 causing items to be stored indefinitely
    $defaultLifetime
);

Configure the Connection

The createConnection() helper method allows creating and configuring a Couchbase Collection class instance using a Data Source Name (DSN) or an array of DSNs:

createConnection() ヘルパー メソッドを使用すると、Data Source Name (DSN) または DSN の配列を使用して Couchbase Collection クラス インスタンスを作成および構成できます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;

// pass a single DSN string to register a single server with the client
$client = CouchbaseCollectionAdapter::createConnection(
    'couchbase://localhost'
    // the DSN can include config options (pass them as a query string):
    // 'couchbase://localhost:11210?operationTimeout=10'
    // 'couchbase://localhost:11210?operationTimeout=10&configTimout=20'
);

// pass an array of DSN strings to register multiple servers with the client
$client = CouchbaseCollectionAdapter::createConnection([
    'couchbase://10.0.0.100',
    'couchbase://10.0.0.101',
    'couchbase://10.0.0.102',
    // etc...
]);

// a single DSN can define multiple servers using the following syntax:
// host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
$client = CouchbaseCollectionAdapter::createConnection(
    'couchbase:?host[localhost]&host[localhost:12345]'
);

Configure the Options

The createConnection() helper method also accepts an array of options as its second argument. The expected format is an associative array of key => value pairs representing option names and their respective values:

createConnection() ヘルパー メソッドは、2 番目の引数としてオプションの配列も受け入れます。期待される形式は、オプション名とそれぞれの値を表すキー => 値ペアの連想配列です。
1
2
3
4
5
6
7
8
9
10
11
12
13
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;

$client = CouchbaseCollectionAdapter::createConnection(
    // a DSN string or an array of DSN strings
    [],

    // associative array of configuration options
    [
        'username' => 'xxxxxx',
        'password' => 'yyyyyy',
        'configTimeout' => '100',
    ]
);

Available Options

username (type: string)
Username for connection CouchbaseCluster.
CouchbaseCluster 接続のユーザー名。
password (type: string)
Password of connection CouchbaseCluster.
CouchbaseCluster 接続のパスワード。
operationTimeout (type: int, default: 2500000)
The operation timeout (in microseconds) is the maximum amount of time the library will wait for an operation to receive a response before invoking its callback with a failure status.
操作のタイムアウト (マイクロ秒単位) は、エラー状態でコールバックを呼び出す前に、操作が応答を受信するのをライブラリが待機する最大時間です。
configTimeout (type: int, default: 5000000)
How long (in microseconds) the client will wait to obtain the initial configuration.
クライアントが初期構成を取得するまで待機する時間 (マイクロ秒単位)。
configNodeTimeout (type: int, default: 2000000)
Per-node configuration timeout (in microseconds).
ノードごとの構成タイムアウト (マイクロ秒単位)。
viewTimeout (type: int, default: 75000000)
The I/O timeout (in microseconds) for HTTP requests to Couchbase Views API.
Couchbase Views API への HTTP リクエストの I/O タイムアウト (マイクロ秒単位)。
httpTimeout (type: int, default: 75000000)
The I/O timeout (in microseconds) for HTTP queries (management API).
HTTP クエリ (管理 API) の I/O タイムアウト (マイクロ秒単位)。
configDelay (type: int, default: 10000)
Config refresh throttling Modify the amount of time (in microseconds) before the configuration error threshold will forcefully be set to its maximum number forcing a configuration refresh.
構成更新スロットリング構成エラーしきい値が強制的に最大数に設定され、構成更新が強制されるまでの時間 (マイクロ秒単位) を変更します。
htconfigIdleTimeout (type: int, default: 4294967295)
Idling/Persistence for HTTP bootstrap (in microseconds).
HTTP ブートストラップのアイドリング/永続性 (マイクロ秒単位)。
durabilityInterval (type: int, default: 100000)
The time (in microseconds) the client will wait between repeated probes to a given server.
特定のサーバーへのプローブが繰り返される間にクライアントが待機する時間 (マイクロ秒単位)。
durabilityTimeout (type: int, default: 5000000)
The time (in microseconds) the client will spend sending repeated probes to a given key's vBucket masters and replicas before they are deemed not to have satisfied the durability requirements.
クライアントが特定のキーの vBucket マスターとレプリカに繰り返しプローブを送信するのに費やす時間 (マイクロ秒単位)。

Tip

ヒント

Reference the Couchbase Collection extension's predefined constants documentation for additional information about the available options.

利用可能なオプションの詳細については、Couchbase Collection 拡張機能の定義済み定数のドキュメントを参照してください。