|
Posted by Jerry Stuckle on 04/18/06 07:13
julian_m wrote:
> I'm just beggining to write some simple-small script which is gonna
> work as a mini chat.
> First aproach:
>
> File: comments.xml
>
> every time this file is accessed, I delete the first line (if number of
> lines is > than x) and add one to the end :
>
> <com>hello</com>
> <com>hello, how are you</com>
> <com>fine, thanks</com>
>
> In client side, I just load this xml inside a div every "n" seconds,
> using ajax
>
> I'm wondering what's going to happen if two or more users try to acces
> to the file at the same time, beacause I don't want to lock the file at
> all...
>
> Is it to use a database a better option? I choice the file option
> beacause I thought that speed would be better.
>
> What would you do?
>
You could corrupt the file.
Either lock the file while you're updating it, or use a database.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|