-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Configurable FastRoute Caching #1749
Conversation
Double negatives give headache. To turn on cache you must use |
I totally agree with you, but don't you think we'll lose consistency with actual FastRoute parameters? Isn't keeping their names the same, makes it more clear, that they are passed straight to the FastRoute function? |
Oh sorry. Yes you are correct, consistency is better. Did not think this through. |
@@ -156,7 +158,11 @@ private function registerDefaultServices($userSettings) | |||
* @return RouterInterface | |||
*/ | |||
$this['router'] = function () { | |||
return new Router; | |||
if ($this['settings']['routerCacheDisabled']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setting may not exist if someone is using their own Container.
Can we have unit tests for this please? |
I'll do my best for the tests :) What exactly do you mean
If I understand, if someone is using their own Container, he/she should add instance of Router (\Slim\Interfaces\RouterInterface) and if he\she wants to use cache, the way is to use public method Slim/Router::setCacheFilePath to do it. |
Sorry for my last post (it was not from my personal, but my company account). |
I mean that you can't assume that those array keys will exist in the |
I vote for setting name |
I am not for this PR, I intentionally left our route caching from the core of the Framework due to the issues it could cause for someone who doesn't understand what it does. This would lead to us having more issues to attend to due to people enabling cache this easy. If you don't remove the cached route file on each deploy, you end up with a broken system. And for this reason I left this out and was planning to add to the documentation how to get it working along with these warnings. |
What are the performance gains? If they are not significant I would favor simplicity too (one less thing to manage). |
Yes KISS principle. |
Thought about this a bit more and I agree with you on KISS. Can you update the PR please and we will look to get this merged in for 3.3.0. |
…hing # Conflicts: # Slim/Container.php
…hing Resolve conflicts
I have two thoughts:
|
Hi |
Throw exception when not able to create cache file - do not check is dir writable or not. Because like @SvenRtbg said I would prefer to precompile cache file during deploy process :) |
The If Slim wants to add nicer behavior and notify the user about the problem, it should check if the cache file exists - it not, the directory should be writeable. Also, an existing cache file should be PHP code returning an array... in fact there are so many details that the FastRoute code takes care of, I think dealing with details of caching should be the task of FastRoute. If the current implementation does not correctly report the problem, send a pull request to FastRoute to deal with it more nicely, and then just use it. |
Thank you. I rebased, which is why this doesn't look like it has been merged, even though it has been. Note that I removed the |
Enabling FastRoute cache can be made.
There are 2 new parameters in main settings that are with same meaning like FastRoute cache aprameters, but prefixed with 'router':
Cache is disabled by default