admin管理员组文章数量:1252714
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.
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.
Share Improve this question edited Nov 15, 2015 at 22:39 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jul 16, 2010 at 14:06 DLiKSDLiKS 1,5964 gold badges21 silver badges32 bronze badges 3- 1 What exactly is it you find 'clunky'? Will the data be changed? What amounts of data are we talking about? How will it be accessed (e.g. loaded into a list in JS?)? – Pontus Gagge Commented Jul 16, 2010 at 14:08
- I just think it would be a waste to have an entire MySQL database just storing a long list of names, if it could be done more efficiently some other way. The data doesn't need to be changed, just more data added over time. It would be a list of around 2000 names and would be loaded (preferably via AJAX) into the client's browser. – DLiKS Commented Jul 16, 2010 at 14:12
- stackoverflow./questions/3265142/… – Anders Commented Jul 16, 2010 at 14:16
3 Answers
Reset to default 5There are a lot of things to think about with this.
- 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?
- 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.
- 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.
本文标签: javascriptBest ServerSide Data Storage Method for Simple DataStack Overflow
版权声明:本文标题:javascript - Best Server-Side Data Storage Method for Simple Data - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740313692a2259902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论