8000 [Cache] Custom pool namespaces · symfony/symfony-docs@526012e · GitHub
[go: up one dir, main page]

Skip to content

Commit 526012e

Browse files
henry2778wouterj
authored andcommitted
[Cache] Custom pool namespaces
1 parent 8a0c09e commit 526012e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

cache.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,53 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
329329
// ...
330330
}
331331

332+
.. tip::
333+
334+
If you need the namespace to be interoperable with a third-party app,
335+
you can take control over auto-generation by setting the ``namespace``
336+
attribute of the ``cache.pool`` service tag. For example, you can
337+
override the service definition of the adapter:
338+
339+
.. configuration-block::
340+
341+
.. code-block:: yaml
342+
343+
# config/services.yaml
344+
services:
345+
app.cache.adapter.redis:
346+
parent: 'cache.adapter.redis'
347+
tags:
348+
- { name: 'cache.pool', namespace: 'my_custom_namespace' }
349+
350+
.. code-block:: xml
351+
352+
<!-- config/services.xml -->
353+
<?xml version="1.0" encoding="UTF-8" ?>
354+
<container xmlns="http://symfony.com/schema/dic/services"
355+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
356+
xsi:schemaLocation="http://symfony.com/schema/dic/services
357+
https://symfony.com/schema/dic/services/services-1.0.xsd">
358+
359+
<services>
360+
<service id="app.cache.adapter.redis" parent="cache.adapter.redis">
361+
<tag name="cache.pool" namespace="my_custom_namespace"/>
362+
</service>
363+
</services>
364+
</container>
365+
366+
.. code-block:: php
367+
368+
// config/services.php
369+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
370+
371+
return function(ContainerConfigurator $configurator) {
372+
$services = $configurator->services();
373+
374+
$services->set('app.cace.adapter.redis')
375+
->parent('cache.adapter.redis')
376+
->tag('cache.pool', ['namespace' => 'my_custom_namespace'])
377+
};
378+
332379
Custom Provider Options
333380
-----------------------
334381

0 commit comments

Comments
 (0)
0