DDC-3379: [GH-1177] Ensure metadata cache is not ArrayCache in production #4175

Closed
opened 2026-01-22 14:36:39 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 8, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of c960657:

Url: https://github.com/doctrine/doctrine2/pull/1177

Message:

This PR adds a new check to Configuration::ensureProductionSettings(). It ensures that the metadata cache does not use ArrayCache in production.

The ArrayCache forgets everything at the end of each request, while the other bundled cache engines (Memcache, MongoDB, FileCache etc.) may keep entries for much longer. The metadata only changes when the source files are changed, so in production the metadata cache only needs to be cleared when new files are deployed, just like the generation of proxy classes.

It is possible to specify/modify metadata dynamically at runtime e.g. using the loadClassMetadata event so that the metadata changes without any changes to the source files, but I assume this is not a supported use-case (at least not without clearing the metadata cache manually). Agree?

The ArrayCache is the default cache engine added by e.g. Doctrine Bundle (for Symfony) and Doctrine ORM Service Provider (for Silex), so most developers are probably not aware of it. However, accessing the metadata at run-time has a significant performance impact (for some anecdotal evidence, see https://github.com/doctrine/common/pull/319#issuecomment-60945429), so a warning in ensureProductionSettings() is relevant.

The PR also fixes the units for ensureProductionSettings() that were previously not being run due to a missing "test" prefix on the ConfigurationTest::ensureProductionSettings method name.

Originally created by @doctrinebot on GitHub (Nov 8, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of c960657: Url: https://github.com/doctrine/doctrine2/pull/1177 Message: This PR adds a new check to Configuration::ensureProductionSettings(). It ensures that the metadata cache does not use ArrayCache in production. The ArrayCache forgets everything at the end of each request, while the other bundled cache engines (Memcache, MongoDB, FileCache etc.) may keep entries for much longer. The metadata only changes when the source files are changed, so in production the metadata cache only needs to be cleared when new files are deployed, just like the generation of proxy classes. It is possible to specify/modify metadata dynamically at runtime e.g. using the loadClassMetadata event so that the metadata changes without any changes to the source files, but I assume this is not a supported use-case (at least not without clearing the metadata cache manually). Agree? The ArrayCache is the default cache engine added by e.g. [Doctrine Bundle](https://github.com/doctrine/DoctrineBundle) (for Symfony) and [Doctrine ORM Service Provider](https://github.com/dflydev/dflydev-doctrine-orm-service-provider/) (for Silex), so most developers are probably not aware of it. However, accessing the metadata at run-time has a significant performance impact (for some anecdotal evidence, see https://github.com/doctrine/common/pull/319#issuecomment-60945429), so a warning in ensureProductionSettings() is relevant. The PR also fixes the units for ensureProductionSettings() that were previously not being run due to a missing "test" prefix on the ConfigurationTest::ensureProductionSettings method name.
admin added the Bug label 2026-01-22 14:36:39 +01:00
admin closed this issue 2026-01-22 14:36:40 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 8, 2014):

@doctrinebot commented on GitHub (Nov 8, 2014): - is referenced by [DDC-3457: [GH-1227] Ensure query cache is not ArrayCache in production](http://www.doctrine-project.org/jira/browse/DDC-3457)
Author
Owner

@doctrinebot commented on GitHub (Nov 10, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1177] was assigned:
https://github.com/doctrine/doctrine2/pull/1177

@doctrinebot commented on GitHub (Nov 10, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1177] was assigned: https://github.com/doctrine/doctrine2/pull/1177
Author
Owner

@doctrinebot commented on GitHub (Nov 11, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Nov 11, 2014): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4175