Skip to content

[Routing][Config] Ability to utilize database resources in router resources/config cache #5159

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

Closed
mlively opened this issue Aug 3, 2012 · 2 comments

Comments

@mlively
Copy link
Contributor

mlively commented Aug 3, 2012

I would like the ability to utilize database other not safely serializable resources in determining resource freshness in the config cache. Specifically for the routing cache.

I am attempting to use a database as a route resource. However to enable it to work with the routing components caching mechanism I need to be able to access my database from the resource.

Unfortunately you can't leave anything like that in state in the resource because it won't unserialize cleanly.

You can't inject anything into the resource after it is unserialized because you don't get an opportunity to work with the resource from the time that it is unserialized in ConfigCache to the time that isFresh() is called.

My initial thought was that if ConfigCache did a check to see if a given resource (after it is unserialized) supported the ContainerAware interface, then the config cache could inject the container for use by isFresh(). However that would result in some fairly large changes throughout the framework and I am not sure if a dependency between the Config component and the Dependency Injection component is appropriate. It would also make for some potentially confusing state issues with resource.

So I am honestly stymied as to an appropriate solution and I don't see a clear workaround that doesn't involve framework changes at some level.

@mpdude
Copy link
Contributor

mpdude commented Feb 25, 2013

Also see #7176

@stof
Copy link
Member

stof commented Apr 9, 2014

Using a database resource for your cached router means that you have to rebuild the cache each time your DB changes, which means you are forced to put the ConfigCache in debug mode in prod. This is a very bad idea for performance.

The proper way to load routes from the DB is to use the extended routing component build by the Symfony CMF project, which avoids breaking the caching for static routes.

@stof stof closed this as completed Apr 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants