Read some texts about locking in PHP.
They all, mainly, direct to http://php.net/manual/en/function.flock.php .
Bu sayfa sabit diskteki bir dosyayı açarken bahsediyor!
Gerçekten öyle mi? Yani, bu gerçekten pahalı kilitleme yapar - bu) Ben sabit diske erişmek gerekecek ben kilitlemek istediğiniz her zaman gelir =
Artık keyifli bir haber beni teselli edebilir?
Edit:
Due to some replies I've got here, I want to ask this;
My script will run only by one thread, or several? Because if it's by one then I obviously don't need a mutex. Is there a concise answer?
What exactly I'm trying to do
Asked by ircmaxell.
This is the story:
I have two ftp servers. I want to be able to show at my website how many online users are online.
So, I thought that these ftp servers will "POST" their stats to a certain PHP script page. Let's assume that the URL of this page is "http://mydomain.com/update.php".
Web sitesinin ana sayfasında ("http://mydomain.com/index.php") ben kümülatif istatistikleri (çevrimiçi kullanıcılar) gösterecektir.
İşte bu.
My problem is that I'm not sure if, when one ftp server updates his stats while another does it too, the info will get mixed.
Like when multi-threading; Two threads increase some "int" variable at the same time. It will not happen as expected unless you sync between them.
So, will I have a problem? Yes, no, maybe?
Possible solution
Thinking hard about it all day long, I have an idea here and I want you to give your opinion.
As said these ftp servers will post their stats, once every 60sec.
I'm thinking about having this file "stats.php".
It will be included at the updating script that the ftp servers go to ("update.php") and at the "index.php" page where visitors see how many users are online.
Now, when an ftp server updates, the script at "update.php" will modify "stats.php" with the new cumulative statistics.
First it will read the stats included at "stats.php", then accumulate, and then rewrite that file.
Yanılmıyorsam eğer PHP dosyası ("stats.php") değiştirilir algılamak ve yeni bir yük olacaktır. Düzeltin?