Skip to content

[Cache] Document using DSN with PDOAdapter #19416

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
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
29 changes: 8 additions & 21 deletions cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,7 @@ Some of these adapters could be configured via shortcuts.
default_psr6_provider: 'app.my_psr6_service'
default_redis_provider: 'redis://localhost'
default_memcached_provider: 'memcached://localhost'
default_pdo_provider: 'app.my_pdo_service'

services:
app.my_pdo_service:
class: \PDO
arguments: ['pgsql:host=localhost']
default_pdo_provider: 'pgsql:host=localhost'

.. code-block:: xml

Expand All @@ -159,24 +154,17 @@ Some of these adapters could be configured via shortcuts.
default-psr6-provider="app.my_psr6_service"
default-redis-provider="redis://localhost"
default-memcached-provider="memcached://localhost"
default-pdo-provider="app.my_pdo_service"
default-pdo-provider="pgsql:host=localhost"
/>
</framework:config>

<services>
<service id="app.my_pdo_service" class="\PDO">
<argument>pgsql:host=localhost</argument>
</service>
</services>
</container>

.. code-block:: php

// config/packages/cache.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework, ContainerConfigurator $container): void {
return static function (FrameworkConfig $framework): void {
$framework->cache()
// Only used with cache.adapter.filesystem
->directory('%kernel.cache_dir%/pools')
Expand All @@ -185,15 +173,14 @@ Some of these adapters could be configured via shortcuts.
->defaultPsr6Provider('app.my_psr6_service')
->defaultRedisProvider('redis://localhost')
->defaultMemcachedProvider('memcached://localhost')
->defaultPdoProvider('app.my_pdo_service')
;

$container->services()
->set('app.my_pdo_service', \PDO::class)
->args(['pgsql:host=localhost'])
->defaultPdoProvider('pgsql:host=localhost')
;
};

.. versionadded:: 7.1

Using a DSN as the provider for the PDO adapter was introduced in Symfony 7.1.

.. _cache-create-pools:

Creating Custom (Namespaced) Pools
Expand Down