Using XML as temporary storage

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Animatro
Forum Newbie
Posts: 3
Joined: Mon Jan 11, 2010 5:14 pm

Using XML as temporary storage

Post by Animatro »

Is it a good idea? If I need data that multiple users can access, but is only going to be temporary and stored for maybe 2 minutes, is XML a good choice?

The reason I'm not using the database is that it gets quite messy and I hear it can result in significant slowdown if there are many users acessing and updating the same data at once. Also the fact that XML is well structured and (relatively) easy to access and work with if a factor here.

Any feedback is appreciated.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Using XML as temporary storage

Post by Christopher »

Animatro wrote:The reason I'm not using the database is that it gets quite messy and I hear it can result in significant slowdown if there are many users acessing and updating the same data at once.
Databases are designed to do what you want and are probably the first choice. I can't imagine that it will be "quite messy" to use a database. And I don't think that XML will be that efficient (which itself is considered messy, verbose, etc.). And ff you are writing while others are reading you will need to implement locking (which databases do implicitly).
(#10850)
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: Using XML as temporary storage

Post by tr0gd0rr »

Messing around with files and file locks will almost certainly be slower than using a database. And you will have to code for race conditions that databases already handle.

You could try an in-memory database storage engine. MySQL for example has a MEMORY engine. It will be faster than a MyISAM engine, but will sit in RAM so you don't want permanent data in there.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Using XML as temporary storage

Post by alex.barylski »

heh...what? Why would a database be messy?

It honestly shouldn't matter what storage type you use, the fear of caching (by itself) being messy is what bugs many developers, because it usually means implementing code in areas where it doesn't feel right, but is to much work to implement else where, so a hack ensues and the code is thus messy (something of a cross cutting concern).

Ultimately though, a DB will probably manage the process more efficiently than XML, if you want real performance, use a cache sub-system that stores temporary data in RAM not on the file system.

XML is best at storing structured/hierarchial data which it excels at (also being more portable and easily editable) otherwise I would think a DB should win every other time.

Cheers,
Alex
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: Using XML as temporary storage

Post by JNettles »

SQLite.
Post Reply