Re: File concurrent file access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 22, 2011 at 10:44 AM, Florian Lemaitre
<florian.lemaitre@xxxxxxxxxxxxxxx> wrote:
> Hi !
>
> I'm developing my new website and I'm worried about concurrent file access.
> In fact, I want to suppress a maximum database interactions so I keep
> information in files with faster I/O than databases.
> But I'm worried by the fact that an error can occur when someone try to
> access a file being edited by a cron task.
>
> Does PHP do all the stuff itself or is there something to do about it ?
>
> PS: I only use file_get_contents, file_put_contentsand unlink on files.
>
> Best regards.
> Florian
>

With file_put_contents you send a flag to lock the file and avoid
concurrency problems, eg:

    file_put_contents('/some/file', 'data', FILE_APPEND | LOCK_EX);

Regards,

Jonathan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux