Skip to content

[Cache] Custom pool namespaces #12527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,53 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
// ...
}

.. tip::

If you need the namespace to be interoperable with a third-party app,
you can take control over auto-generation by setting the ``namespace``
attribute of the ``cache.pool`` service tag. For example, you can
override the service definition of the adapter:

.. configuration-block::

.. code-block:: yaml

# config/services.yaml
services:
app.cache.adapter.redis:
parent: 'cache.adapter.redis'
tags:
- { name: 'cache.pool', namespace: 'my_custom_namespace' }

.. code-block:: xml

<!-- config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.cache.adapter.redis" parent="cache.adapter.redis">
<tag name="cache.pool" namespace="my_custom_namespace"/>
</service>
</services>
</container>

.. code-block:: php

// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return function(ContainerConfigurator $configurator) {
$services = $configurator->services();

$services->set('app.cace.adapter.redis')
->parent('cache.adapter.redis')
->tag('cache.pool', ['namespace' => 'my_custom_namespace'])
};

Custom Provider Options
-----------------------

Expand Down