Deprecate using doctrine/cache for metadata caching #6700

Closed
opened 2026-01-22 15:37:16 +01:00 by admin · 3 comments
Owner

Originally created by @alcaeus on GitHub (Apr 22, 2021).

Originally assigned to: @alcaeus on GitHub.

With doctrine/cache being sunset, and doctrine/persistence supporting PSR-6 caches in metadata factories, it's time to update the ORM configuration class to also accept PSR-6 caches. When setting up the metadata factory, the adapters provided in doctrine/cache should be used to avoid calling deprecated methods in doctrine/persistence.

Originally created by @alcaeus on GitHub (Apr 22, 2021). Originally assigned to: @alcaeus on GitHub. With doctrine/cache being sunset, and doctrine/persistence supporting PSR-6 caches in metadata factories, it's time to update the ORM configuration class to also accept PSR-6 caches. When setting up the metadata factory, the adapters provided in doctrine/cache should be used to avoid calling deprecated methods in doctrine/persistence.
admin added the Deprecation label 2026-01-22 15:37:16 +01:00
admin closed this issue 2026-01-22 15:37:16 +01:00
Author
Owner

@nataniel commented on GitHub (Jun 24, 2021):

https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/reference/advanced-configuration.html

The documentation says to use:

$cache = new \Doctrine\Common\Cache\ArrayCache;
$config->setMetadataCacheImpl($cache);

but the dependency on doctrine/orm 2.9.3 is:
"doctrine/cache": "^1.11.3|^2.0.3",

and 2.0.3 removed ArrayCache.

So I'm not really sure what is the current state and I cannot find any proper documentation on how to configure EntityManager :(

@nataniel commented on GitHub (Jun 24, 2021): https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/reference/advanced-configuration.html The documentation says to use: ``` $cache = new \Doctrine\Common\Cache\ArrayCache; $config->setMetadataCacheImpl($cache); ``` but the dependency on doctrine/orm 2.9.3 is: `"doctrine/cache": "^1.11.3|^2.0.3",` and 2.0.3 removed ArrayCache. So I'm not really sure what is the current state and I cannot find any proper documentation on how to configure EntityManager :(
Author
Owner

@StrikeAgainst commented on GitHub (Jul 27, 2021):

Same goes for PhpFileCache, which has also been removed, but the documentation still suggests to use it for caching. Supposedly symfony/cache is a recommended substitute, but I can find no documentation on how to get it working with Doctrine. I hope someone fixes the current documentation soon... For now I'll downgrade doctrine/cache I guess.

@StrikeAgainst commented on GitHub (Jul 27, 2021): Same goes for `PhpFileCache`, which has also been removed, but the [documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/reference/caching.html#caching) still suggests to use it for caching. Supposedly `symfony/cache` is a recommended substitute, but I can find no documentation on how to get it working with Doctrine. I hope someone fixes the current documentation soon... For now I'll downgrade `doctrine/cache` I guess.
Author
Owner

@ghdi commented on GitHub (Jul 28, 2021):

@nataniel / @StrikeAgainst

This worked for me:

$cache = new \Symfony\Component\Cache\Adapter\ApcuAdapter();

$cacheProvider = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap($cache);

$doctrineConfig->setMetadataCacheImpl($cacheProvider);
@ghdi commented on GitHub (Jul 28, 2021): @nataniel / @StrikeAgainst This worked for me: ``` $cache = new \Symfony\Component\Cache\Adapter\ApcuAdapter(); $cacheProvider = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap($cache); $doctrineConfig->setMetadataCacheImpl($cacheProvider); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6700