Reputation: 17243
I'm looking for a way to lock a file so no more than one request can read, write or delete it at a time. I hear flock()
is meant for that. However I'm running on Linux, and I've read that flock()
is 'advisory' on Linux.
So my question to you: can I count on flock()
to reliably lock my files with PHP running over Apache on Linux? Or should I look for a different approach?
Upvotes: 2
Views: 370
Reputation: 2689
Advisory means that processes can ignore the flock
if they want to. If you are in control of the file and consistently use flock
, you are fine. If the file can be manipulated by other processes, then you may have a problem.
Upvotes: 4