8000 minor #15764 [Cache] Add CouchbaseCollectionAdapter compatibility wit… · symfony/symfony-docs@4c4dfdb · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c4dfdb

Browse files
committed
minor #15764 [Cache] Add CouchbaseCollectionAdapter compatibility with sdk 3.0.0 (ajcerezo)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Cache] Add CouchbaseCollectionAdapter compatibility with sdk 3.0.0 With this pull request add documentation CouchbaseCollectionAdapter for cache system. Commits ------- da91d39 [Cache] Add CouchbaseCollectionAdapter compatibility with sdk 3.0.0
2 parents eb1ffd3 + da91d39 commit 4c4dfdb

File tree

2 files changed

+148
-5
lines changed

2 files changed

+148
-5
lines changed

components/cache/adapters/couchbasebucket_adapter.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ is also available.
2222

2323
**Requirements:** The `Couchbase PHP extension`_ as well as a `Couchbase server`_
2424
must be installed, active, and running to use this adapter. Version ``2.6`` or
25-
greater of the `Couchbase PHP extension`_ is required for this adapter.
25+
less than 3.0 of the `Couchbase PHP extension`_ is required for this adapter.
2626

2727
This adapter expects a `Couchbase Bucket`_ instance to be passed as the first
2828
parameter. A namespace and default cache lifetime can optionally be passed as
@@ -32,17 +32,17 @@ the second and third parameters::
3232

3333
$cache = new CouchbaseBucketAdapter(
3434
// the client object that sets options and adds the server instance(s)
35-
\CouchbaseBucket $client,
35+
$client,
3636

3737
// the name of bucket
38-
string $bucket,
38+
$bucket,
3939

4040
// a string prefixed to the keys of the items stored in this cache
41-
$namespace = '',
41+
$namespace,
4242

4343
// the default lifetime (in seconds) for cache items that do not define their
4444
// own lifetime, with a value 0 causing items to be stored indefinitely
45-
$defaultLifetime = 0,
45+
$defaultLifetime
4646
);
4747

4848

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
.. index::
2+
single: Cache Pool
3+
single: Couchabase Cache
4+
5+
.. _couchbase-collection-adapter:
6+
7+
Couchbase Cache Adapter
8+
=======================
9+
10+
This adapter stores the values in-memory using one (or more) `Couchbase server`_
11+
instances. Unlike the :ref:`APCu adapter <apcu-adapter>`, and similarly to the
12+
:ref:`Memcached adapter <memcached-adapter>`, it is not limited to the current server's
13+
shared memory; you can store contents independent of your PHP environment.
14+
The ability to utilize a cluster of servers to provide redundancy and/or fail-over
15+
is also available.
16+
17+
.. caution::
18+
19+
**Requirements:** The `Couchbase PHP extension`_ as well as a `Couchbase server`_
20+
must be installed, active, and running to use this adapter. Version ``3.0`` or
21+
greater of the `Couchbase PHP extension`_ is required for this adapter.
22+
23+
This adapter expects a `Couchbase Collection`_ instance to be passed as the first
24+
parameter. A namespace and default cache lifetime can optionally be passed as
25+
the second and third parameters::
26+
27+
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;
28+
29+
$cache = new CouchbaseCollectionAdapter(
30+
// the client object that sets options and adds the server instance(s)
31+
$client,
32+
33+
// a string prefixed to the keys of the items stored in this cache
34+
$namespace,
35+
36+
// the default lifetime (in seconds) for cache items that do not define their
37+
// own lifetime, with a value 0 causing items to be stored indefinitely
38+
$defaultLifetime
39+
);
40+
41+
42+
Configure the Connection
43+
------------------------
44+
45+
The :method:`Symfony\\Component\\Cache\\Adapter\\CouchbaseCollectionAdapter::createConnection`
46+
helper method allows creating and configuring a `Couchbase Collection`_ class instance using a
47+
`Data Source Name (DSN)`_ or an array of DSNs::
48+
49+
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;
50+
51+
// pass a single DSN string to register a single server with the client
52+
$client = CouchbaseCollectionAdapter::createConnection(
53+
'couchbase://localhost'
54+
// the DSN can include config options (pass them as a query string):
55+
// 'couchbase://localhost:11210?operationTimeout=10'
56+
// 'couchbase://localhost:11210?operationTimeout=10&configTimout=20'
57+
);
58+
59+
// pass an array of DSN strings to register multiple servers with the client
60+
$client = CouchbaseCollectionAdapter::createConnection([
61+
'couchbase://10.0.0.100',
62+
'couchbase://10.0.0.101',
63+
'couchbase://10.0.0.102',
64+
// etc...
65+
]);
66+
67+
// a single DSN can define multiple servers using the following syntax:
68+
// host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
69+
$client = CouchbaseCollectionAdapter::createConnection(
70+
'couchbase:?host[localhost]&host[localhost:12345]'
71+
);
72+
73+
74+
Configure the Options
75+
---------------------
76+
77+
The :method:`Symfony\\Component\\Cache\\Adapter\\CouchbaseCollectionAdapter::createConnection`
78+
helper method also accepts an array of options as its second argument. The
79+
expected format is an associative array of ``key => value`` pairs representing
80+
option names and their respective values::
81+
82+
use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter;
83+
84+
$client = CouchbaseCollectionAdapter::createConnection(
85+
// a DSN string or an array of DSN strings
86+
[],
87+
88+
// associative array of configuration options
89+
[
90+
'username' => 'xxxxxx',
91+
'password' => 'yyyyyy',
92+
'configTimeout' => '100',
93+
]
94+
);
95+
96+
Available Options
97+
~~~~~~~~~~~~~~~~~
98+
99+
``username`` (type: ``string``)
100+
Username for connection ``CouchbaseCluster``.
101+
102+
``password`` (type: ``string``)
103+
Password of connection ``CouchbaseCluster``.
104+
105+
``operationTimeout`` (type: ``int``, default: ``2500000``)
106+
The operation timeout (in microseconds) is the maximum amount of time the library will
107+
wait for an operation to receive a response before invoking its callback with a failure status.
108+
109+
``configTimeout`` (type: ``int``, default: ``5000000``)
110+
How long (in microseconds) the client will wait to obtain the initial configuration.
111+
112+
``configNodeTimeout`` (type: ``int``, default: ``2000000``)
113+
Per-node configuration timeout (in microseconds).
114+
115+
``viewTimeout`` (type: ``int``, default: ``75000000``)
116+
The I/O timeout (in microseconds) for HTTP requests to Couchbase Views API.
117+
118+
``httpTimeout`` (type: ``int``, default: ``75000000``)
119+
The I/O timeout (in microseconds) for HTTP queries (management API).
120+
121+
``configDelay`` (type: ``int``, default: ``10000``)
122+
Config refresh throttling
123+
Modify the amount of time (in microseconds) before the configuration error threshold will forcefully be set to its maximum number forcing a configuration refresh.
124+
125+
``htconfigIdleTimeout`` (type: ``int``, default: ``4294967295``)
126+
Idling/Persistence for HTTP bootstrap (in microseconds).
127+
128+
``durabilityInterval`` (type: ``int``, default: ``100000``)
129+
The time (in microseconds) the client will wait between repeated probes to a given server.
130+
131+
``durabilityTimeout`` (type: ``int``, default: ``5000000``)
132+
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.
133+
134+
.. tip::
135+
136+
Reference the `Couchbase Collection`_ extension's `predefined constants`_ documentation
137+
for additional information about the available options.
138+
139+
.. _`Couchbase PHP extension`: https://docs.couchbase.com/sdk-api/couchbase-php-client/namespaces/couchbase.html
140+
.. _`predefined constants`: https://docs.couchbase.com/sdk-api/couchbase-php-client/classes/Couchbase-Bucket.html
141+
.. _`Couchbase server`: https://couchbase.com/
142+
.. _`Couchbase Collection`: https://docs.couchbase.com/sdk-api/couchbase-php-client/classes/Couchbase-Collection.html
143+
.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name

0 commit comments

Comments
 (0)
0