Do I need to care about race conditions when using PHP output buffering?
I would like to cache the result of a 开发者_运维百科single php file (for a few minutes). Having read a few articles, this seems pretty easy, e.g. following http://www.addedbytes.com/articles/caching-output-in-php/
However, at the end of http://simas.posterous.com/php-data-caching-techniques, the author says that file locking should be done and I cannot see locking in any examples online. Is this required? How should I do it?
Thanks a lot!
We use Nette's NSafeStream class for this - it provides thread safe file access:
NSafeStream
You don't need to use rest of the framework, you can use just this class.
Take a look at this : http://php.net/manual/en/function.flock.php
精彩评论