Giter Club home page Giter Club logo

Comments (7)

lcobucci avatar lcobucci commented on June 24, 2024

@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.

sutem avatar sutem commented on June 24, 2024

@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.

lcobucci avatar lcobucci commented on June 24, 2024

I don't follow... Is this for development environment? If so, why do have caching enabled?

from mezzio-fastroute.

sutem avatar sutem commented on June 24, 2024

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.

lcobucci avatar lcobucci commented on June 24, 2024

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.

sutem avatar sutem commented on June 24, 2024

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.

pine3ree avatar pine3ree commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.