DLiKS
DLiKS

Reputation: 1596

Best Server-Side Data Storage Method for Simple Data

I'm coding a website that involves storing very simple data, just a very long list of names with no additional data, on the server. As this data is so simple, I don't really want to use MySQL (it would be a bit too clunky) so I'm asking what's the best way to store very simple data on the server.

I definitely would favour speed over anything else, and easy access to the data via javascript and AJAX would be very good too as the rest of the site is coded in javascript/jQuery. I don't really care if the data can be viewed freely (as it will be available anyway), as long as it can't be changed by unauthorised users.

Upvotes: 8

Views: 8256

Answers (3)

Mitchel Sellers
Mitchel Sellers

Reputation: 63126

There are a lot of things to think about with this.

  1. Is the information the same for all users with just a single set that applies to all users out there? Or is there a separate set of data for each user?
  2. How is the data going to be served to the client, my guess here is that you would be having a web service or otherwise that might return a JSON.
  3. From a security standpoint, do you want someone to be able to just "grab" the data and run?

Personally I find that a database if often a better choice, but otherwise i would use an XML file. Keep in mind though that you have to be careful with loading/reading of XML files to serve web requests to prevent any potential file locking issues.

Upvotes: 5

Evan
Evan

Reputation: 3306

Write it to a file and save the data as a serialized object. This way when you read in the data it's instantly accessible as the variable type you need (array, obj, etc). This will be faster than XML parsing.

Upvotes: 3

Aaron
Aaron

Reputation: 423

Use an XML file that is web-accessible. Then you can query the XML file from the browser if need be, and still parse/write it in PHP. You'll want to use the flock function in PHP to make sure that two instances of a page don't try to write to the file at the same time.

Upvotes: 3

Related Questions