开发者

Saving widget settings: php file vs db [apc installed]

What would be faster in terms of performance and usability of editin开发者_C百科g etc.

Storing the settings for widget in a file or storing the settings for it in a db.

There are about 23 settings for the widget.

The settings in the file will be stored as vars and saved as a php file.

The settings in the database will be stored as serilized and then retrieved. But after one retrieval they will be cached for about 5 minutes in a php file as an array. So basically the database class will cache the results and then this would be used. What do you suggest is better to be used.

I also wanna give the user the option to edit the widget, so please throw me some answers. Another issue was that if I was to check which widgets are owned to the a member on a file system with file names linke memberid_filename, how would i do it?


A database is definitely the right choice if you're going to have multiple copies of the settings (if, say, each user on your site can customize it.)

Saving vars to a PHP file is only a good idea if it isn't receiving input from the internet. If it is, a malicious user could escape the var with a quote-semicolon and then add arbitrary PHP commands, arguably worse than SQL injection! Whoops.

Your proposed caching setup is a little weird. I'm not saying it won't be helpful, but I'm not so sure it will be either. A competent database (like Postgres) will cache your queries anyway, taking care of that aspect of the performance tuning for you.

The way I'd store ownership data on the widget is via a table, let's call it widget_owners. Each column would contain the userID, ID of the widget (important assuming you want to be able to track ownership of new widgets without doing ugly things to your database to support it) and any relevant privileges.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜