zendframework / zend-modulemanager

ModuleManager component from Zend Framework
BSD 3-Clause "New" or "Revised" License
44 stars 27 forks source link

Write cache to temporary file first and then rename #88

Closed michalbundyra closed 5 years ago

michalbundyra commented 5 years ago

Alternative solution for issue reported in #87.

The problem is that every process running process check if the cache file exists and if it doesn't it tries to create it. In case of big configuration creating cache file can take a while. And while it is generated other process can read "malformed" file, which is the issue.

As locking file does not work out of the box with include/require (see: https://bugs.php.net/bug.php?id=52895) we can add flock around include/require (where the cache file is read) or apply the solution from this PR.

Not sure how we can test it in a right and easy way. Also, not sure if locking solution is gonna be better - how we can measure performance of both approaches?

/cc @rutek @Xerkus