开发者

Do I need to care about race conditions when using PHP output buffering?

开发者 https://www.devze.com 2023-02-10 01:04 出处:网络
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-

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号