Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Add new cache.adapter.doctrine_dbal #16502

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

Open
wants to merge 1 commit into
base: 5.4
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ The Cache component comes with a series of adapters pre-configured:
* :doc:`cache.adapter.apcu </components/cache/adapters/apcu_adapter>`
* :doc:`cache.adapter.array </components/cache/adapters/array_cache_adapter>`
* :doc:`cache.adapter.doctrine </components/cache/adapters/doctrine_adapter>`
* :doc:`cache.adapter.doctrine_dbal </components/cache/adapters/pdo_doctrine_dbal_adapter>`
* :doc:`cache.adapter.filesystem </components/cache/adapters/filesystem_adapter>`
* :doc:`cache.adapter.memcached </components/cache/adapters/memcached_adapter>`
* :doc:`cache.adapter.pdo </components/cache/adapters/pdo_doctrine_dbal_adapter>`
Expand All @@ -116,6 +117,10 @@ The Cache component comes with a series of adapters pre-configured:

``cache.adapter.redis_tag_aware`` has been introduced in Symfony 5.2.

.. versionadded:: 5.4

``cache.adapter.doctrine_dbal`` has been introduced in Symfony 5.4.

Some of these adapters could be configured via shortcuts. Using these shortcuts
will create pools with service IDs that follow the pattern ``cache.[type]``.

Expand All @@ -138,6 +143,8 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
default_memcached_provider: 'memcached://localhost'
# service: cache.pdo
default_pdo_provider: 'doctrine.dbal.default_connection'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PDO adapter no longer accept DBAL Connection. This line needs an update too.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the availability of "doctrine/dbal": https://github.com/symfony/framework-bundle/blob/5.4/DependencyInjection/Configuration.php#L1082
If available: database_connection

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the default config missing an update? DBAL doesn't extend PDO anymore, isn't it? So we can't set a default value here (unless we can access the PDO object when we have a DBAL connection?)
Would anyone like to dig this question?

# service: cache.doctrine_dbal
default_doctrine_dbal_provider: 'doctrine.dbal.default_connection'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this here too, as the service cache.default_doctrine_dbal_provider is registered as an alias of service doctrine.dbal.default_connection.

However, i'm not sure to understand properly this part of the doc. As far as i understand, a new pool should be created, named cache.doctrine_dbal, and I should be able to use it, but I don't see such a pool in my list of service.
Did I miss something ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/symfony/framework-bundle/blob/5.4/DependencyInjection/Configuration.php#L1081

Suggested change
default_doctrine_dbal_provider: 'doctrine.dbal.default_connection'
default_doctrine_dbal_provider: 'database_connection'


.. code-block:: xml

Expand All @@ -158,6 +165,7 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
default_redis_provider: Service: cache.redis
default_memcached_provider: Service: cache.memcached
default_pdo_provider: Service: cache.pdo
default_doctrine_dbal_provider: Service: cache.doctrine_dbal
-->
<!-- "directory" attribute is only used with cache.adapter.filesystem -->
<framework:cache directory="%kernel.cache_dir%/pools"
Expand All @@ -166,6 +174,7 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
default_redis_provider="redis://localhost"
default_memcached_provider="memcached://localhost"
default_pdo_provider="doctrine.dbal.default_connection"
default_doctrine_dbal_provider="doctrine.dbal.default_connection"
/>
</framework:config>
</container>
Expand All @@ -189,6 +198,8 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
->defaultMemcachedProvider('memcached://localhost')
// Service: cache.pdo
->defaultPdoProvider('doctrine.dbal.default_connection')
// Service: cache.doctrine_dbal
->defaultDoctrineDbalProvider('doctrine.dbal.default_connection')
;
};

Expand Down