Comments (7)
@sutem that is the expected behaviour. You are supposed the clean up cached file and the opcache when deploying a new version.
from mezzio-fastroute.
@lcobucci I completely agree with you. But this is not about deploy. In this situation, we need to be sure that deleting the cache file will trigger the creation of a new one.
from mezzio-fastroute.
I don't follow... Is this for development environment? If so, why do have caching enabled?
from mezzio-fastroute.
What I'm trying to say is that include can return a file even if it was deleted, because it remains in the php cache. To prevent this unexpected behavior, you should use file_exists and only then include the file.
$dispatchData = file_exists($this->cacheFile) ? include $this->cacheFile : false;
from mezzio-fastroute.
That suggestion implies in having extra and unnecessary io calls.
This process is optimised for production environments, if you want to have manual interventions to remove the file you should also take the responsibility for cleaning up the opcache.
Alternatively, you may decide not to use cache which will always give you the updated version of routes.
Does this make sense to you?
from mezzio-fastroute.
That suggestion implies in having extra and unnecessary io calls.
I don't think it's too scary php-bench
This process is optimised for production environments, if you want to have manual interventions to remove the file you should also take the responsibility for cleaning up the opcache.
Clearing opcache is an incorrect option, because the application will depend on the caching technology used.
Alternatively, you may decide not to use cache which will always give you the updated version of routes.
This is also not suitable, because it greatly affects performance.
Does this make sense to you?
I just want others to save time when they encounter my problem, because it is not as simple as it seems. I solved my local problem, but it occurred because the current implementation of the method does ignore php opcode caching.
from mezzio-fastroute.
Hello @sutem,
you could also use the opcache_invalidate
for the routes cache-file alone, once per request. This should not affect performance (at least it doesn't in ssd disks) and this is what I usually do for files I need to be sure they exists before their opcode expiration (opcache.revalidate_freq
).
If we want to add this as an optional feature we must also check that php opcode cache (and not a different kind of opcode caching) is enabled.
kind regards
from mezzio-fastroute.
Related Issues (9)
- Fix uri generation for custom parser HOT 1
- `FastRouteRouter#getCacheFile` to provide cache location HOT 3
- FastRouteRouter->addRoute() does not throw a RuntimeException of called after either match() or geerateUri() HOT 2
- Dependency Dashboard
- Route option values should be retrievable from request attribute HOT 2
- Psalm integration
- PHP 8.0 support
- Broken link on the documentation page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mezzio-fastroute.