Skip to content

Commit e119c4a

Browse files
committed
Merge branch '5.0'
* 5.0: [FIX] Custom pool
2 parents 675bf47 + bba98b5 commit e119c4a

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
@@ -202,7 +202,7 @@ You can also create more customized pools:
202202
# creates a "my_cache_pool" service
203203
# autowireable via "CacheInterface $myCachePool"
204204
my_cache_pool:
205-
adapter: cache.adapter.array
205+
adapter: cache.adapter.filesystem
206206
207207
# uses the default_memcached_provider from above
208208
acme.cache:
@@ -240,7 +240,7 @@ You can also create more customized pools:
240240
241241
<!-- creates a "my_cache_pool" service
242242
autowireable via "CacheInterface $myCachePool" -->
243-
<framework:pool name="my_cache_pool" adapter="cache.adapter.array"/>
243+
<framework:pool name="my_cache_pool" adapter="cache.adapter.filesystem"/>
244244
245245
<!-- uses the default_memcached_provider from above -->
246246
<framework:pool name="acme.cache" adapter="cache.adapter.memcached"/>
@@ -274,14 +274,66 @@ You can also create more customized pools:
274274
// creates a "my_cache_pool" service
275275
// autowireable via "CacheInterface $myCachePool"
276276
'my_cache_pool' => [
277-
'adapter' => 'cache.adapter.array',
277+
'adapter' => 'cache.adapter.filesystem',
278278
],
279279
280280
// uses the default_memcached_provider from above
281281
'acme.cache' => [
282282
'adapter' => 'cache.adapter.memcached',
283283
],
284284
285+
'cache.foobar' => [
286+
'adapter' => 'cache.adapter.memcached',
287+
'provider' => 'memcached://user:password@example.com',
288+
],
289+
],
290+
],
291+
]);
292+
293+
The configuration above will create 3 services: ``my_cache_pool``, ``cache.acme``
294+
and ``cache.foobar``. The ``my_cache_pool`` pool is using the filesystem adapter
295+
and the other two are using the :doc:`MemcachedAdapter </components/cache/adapters/memcached_adapter>`.
296+
The ``cache.acme`` pool is using the Memcached server on localhost and ``cache.foobar``
297+
is using the Memcached server at example.com.
298+
299+
For advanced configurations it could sometimes be useful to use a pool as an adapter.
300+
301+
.. configuration-block::
302+
303+
.. code-block:: yaml
304+
305+
# app/config/config.yml
306+
framework:
307+
cache:
308+
app: my_configured_app_cache
309+
pools:
310+
my_cache_pool:
311+
adapter: cache.adapter.memcached
312+
provider: 'memcached://user:password@example.com'
313+
cache.short_cache:
314+
adapter: my_cache_pool
315+
default_lifetime: 60
316+
cache.long_cache:
317+
adapter: my_cache_pool
318+
default_lifetime: 604800
319+
my_configured_app_cache:
320+
# "cache.adapter.filesystem" is the default for "cache.app"
321+
adapter: cache.adapter.filesystem
322+
default_lifetime: 3600
323+
324+
.. code-block:: xml
325+
326+
<!-- app/config/config.xml -->
327+
<?xml version="1.0" encoding="UTF-8" ?>
328+
<container xmlns="http://symfony.com/schema/dic/services"
329+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
330+
xmlns:framework="http://symfony.com/schema/dic/symfony"
331+
xsi:schemaLocation="http://symfony.com/schema/dic/services
332+
https://symfony.com/schema/dic/services/services-1.0.xsd
333+
http://symfony.com/schema/dic/symfony
334+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
335+
>>>>>>> 3.4
336+
285337
// control adapter's configuration
286338
'foobar.cache' => [
287339
'adapter' => 'cache.adapter.memcached',

0 commit comments

Comments
 (0)