How to clear PHP APCu cache if new version of the script is runnig?

459 views Asked by At

I`m developing a simple PHP application that is launched on an Apache2. I use APCu to speed up some parts of the application and use a special key for each part and package. The application is based on Composer and some time I need to update application scripts while the site is live.

I`m looking for a way to clear the cache if the version of the application is changed dynamically.

1

There are 1 answers

0
Mostafa Barmshory On BEST ANSWER

Finally, I found a very simple and effective solution. The best way to clean the cache on a project update is to put the script in composer. Here is an example:

{
    "scripts": {
        "post-update-cmd": "Util\\CacheController::clearCache()"
    }
}

Where the clearCache function will remove all cached data. So whenever anyone tries to update the project, then the cache will be removed.