Skip to content

Commit 85f654b

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Add a versionadded directive [Cache] Add CouchbaseCollectionAdapter compatibility with sdk 3.0.0
2 parents e8c5ec8 + 15084a8 commit 85f654b

File tree

2 files changed

+152
-5
lines changed

2 files changed

+152
-5
lines changed

components/cache/adapters/couchbasebucket_adapter.rst

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

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

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

2929
$cache = new CouchbaseBucketAdapter(
3030
// the client object that sets options and adds the server instance(s)
31-
\CouchbaseBucket $client,
31+
$client,
3232

3333
// the name of bucket
34-
string $bucket,
34+
$bucket,
3535

3636
// a string prefixed to the keys of the items stored in this cache
37-
$namespace = '',
37+
$namespace,
3838

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

4444

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

0 commit comments

Comments
 (0)