file vs database. mini chat script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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, 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

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?

Re: file vs database. mini chat script

julian_m wrote:
Quoted text here. Click to load it

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.

Site Timeline