You are here: Re: [PHP] Locking in PHP (Question for PHP Gurus) « PHP « IT news, forums, messages
Re: [PHP] Locking in PHP (Question for PHP Gurus)

Posted by Rasmus Lerdorf on 04/07/05 06:49

Cabbar Duzayak wrote:
> Hi All,
>
> I am using PHP on Apache/Linux with mod_php4. I need to implement a
> lazy cache for some resource which should be updated say every 1 hour
> in a way that the first person who arrives after an hour will be
> updating the cache. As you can imagine, I need to implement a write
> lock in this case, the idea is:

Why? As long as you do an atomic replace of the cache data, you
shouldn't have any problems. You may have 2 requests both trying to
create the new cache entry, but that is much cleaner than having to deal
with locking. Do a tempnam() to get a temp file to write to and then do
a rename() if this is a filesystem thing.

Basically avoid locking at all costs in a web app.

-Rasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация