开发者

Best Server-Side Data Storage Method for Simple Data

开发者 https://www.devze.com 2023-01-07 09:59 出处:网络
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 wo

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 o开发者_如何学Pythonver 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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消