file vs database. mini chat script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • julian_m

    #1

    file vs database. mini chat script

    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?

  • Jerry Stuckle

    #2
    Re: file vs database. mini chat script

    julian_m wrote:[color=blue]
    > 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?
    >[/color]

    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@attgl obal.net
    =============== ===

    Comment

    Working...