Skip to content

Commit da331a5

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: [FIX] Custom pool
2 parents 5311238 + fc483d9 commit da331a5

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

cache.rst

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ You can also create more customized pools:
206206
# creates a "my_cache_pool" service
207207
# autowireable via "CacheInterface $myCachePool"
208208
my_cache_pool:
209-
adapter: cache.adapter.array
209+
adapter: cache.adapter.filesystem
210210
211211
# uses the default_memcached_provider from above
212212
acme.cache:
@@ -244,7 +244,7 @@ You can also create more customized pools:
244244
245245
<!-- creates a "my_cache_pool" service
246246
autowireable via "CacheInterface $myCachePool" -->
247-
<framework:pool name="my_cache_pool" adapter="cache.adapter.array"/>
247+
<framework:pool name="my_cache_pool" adapter="cache.adapter.filesystem"/>
248248
249249
<!-- uses the default_memcached_provider from above -->
250250
<framework:pool name="acme.cache" adapter="cache.adapter.memcached"/>
@@ -278,14 +278,66 @@ You can also create more customized pools:
278278
// creates a "my_cache_pool" service
279279
// autowireable via "CacheInterface $myCachePool"
280280
'my_cache_pool' => [
281-
'adapter' => 'cache.adapter.array',
281+
'adapter' => 'cache.adapter.filesystem',
282282
],
283283
284284
// uses the default_memcached_provider from above
285285
'acme.cache' => [
286286
'adapter' => 'cache.adapter.memcached',
287287
],
288288
289+
'cache.foobar' => [
290+
'adapter' => 'cache.adapter.memcached',
291+
'provider' => 'memcached://user:password@example.com',
292+
],
293+
],
294+
],
295+
]);
296+
297+
The configuration above will create 3 services: ``my_cache_pool``, ``cache.acme``
298+
and ``cache.foobar``. The ``my_cache_pool`` pool is using the filesystem adapter
299+
and the other two are using the :doc:`MemcachedAdapter </components/cache/adapters/memcached_adapter>`.
300+
The ``cache.acme`` pool is using the Memcached server on localhost and ``cache.foobar``
301+
is using the Memcached server at example.com.
302+
303+
For advanced configurations it could sometimes be useful to use a pool as an adapter.
304+
305+
.. configuration-block::
306+
307+
.. code-block:: yaml
308+
309+
# app/config/config.yml
310+
framework:
311+
cache:
312+
app: my_configured_app_cache
313+
pools:
314+
my_cache_pool:
315+
adapter: cache.adapter.memcached
316+
provider: 'memcached://user:password@example.com'
317+
cache.short_cache:
318+
adapter: my_cache_pool
319+
default_lifetime: 60
320+
cache.long_cache:
321+
adapter: my_cache_pool
322+
default_lifetime: 604800
323+
my_configured_app_cache:
324+
# "cache.adapter.filesystem" is the default for "cache.app"
325+
adapter: cache.adapter.filesystem
326+
default_lifetime: 3600
327+
328+
.. code-block:: xml
329+
330+
<!-- app/config/config.xml -->
331+
<?xml version="1.0" encoding="UTF-8" ?>
332+
<container xmlns="http://symfony.com/schema/dic/services"
333+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
334+
xmlns:framework="http://symfony.com/schema/dic/symfony"
335+
xsi:schemaLocation="http://symfony.com/schema/dic/services
336+
https://symfony.com/schema/dic/services/services-1.0.xsd
337+
http://symfony.com/schema/dic/symfony
338+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
339+
>>>>>>> 3.4
340+
289341
// control adapter's configuration
290342
'foobar.cache' => [
291343
'adapter' => 'cache.adapter.memcached',

0 commit comments

Comments
 (0)