anyone who REALY knows about file locking?
| From: | Justin French | Date: | Wed, 11 Oct 2000 02:29:59 +0000 |
| Subject: | anyone who REALY knows about file locking? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-19466@lists.php.net to get a copy of this message | ||
hi,
i'm after some sample code of correct file locking
procedures. I'm working on a high traffic site, and
do not want to loose information due to overwriting
or anything like that, especially if two people try
and do the same thing at the same time.
what happens when person A accesses the file, has it
locked, and person B tries to open it? does the PHP
script wait until it's unlocked, or does it return
an error? is there a timeout? has any one realy
pushed this stuff, or do we just bang it together &
hope flock() does a good job?
What am i after?
- sample code for correct locking procedure which
covers all my queries above, and any i've missed
- any information / testing results as to what happens
when people try to access a locked file
- any tutorials or anything that realy pushes the
file locking stuff, making sure i won't get errors
or "file cannot be accessed" stuff when there is
simultaneous attempts to work with a file.
I know that in most cases --and in this case-- that
the chances of two people writing to a file at the
same instant is highly unlikely, and that the writing
process could only take half a second or less (probably
appending under 1K to a flat text file), but i think
this is an area where perfection is probably worth a
little effort :)
Thanks in advance,
Justin French