开发者

Store app settings in Database

开发者 https://www.devze.com 2023-03-17 05:03 出处:网络
We have lot appSettings in our asp.net application. Is it a good idea to move开发者_如何学C them to database. I know one advantage is it is easy to maintain and do administrative activities. I need to

We have lot appSettings in our asp.net application. Is it a good idea to move开发者_如何学C them to database. I know one advantage is it is easy to maintain and do administrative activities. I need to know if someone has faced any issues.


We do not have any appsettings in the config but maintains a seperate DB table as the amount of configuration is huge. There is no issue with that. Of course we have to use some caching to prevent too much of queries related to config information.


There are a number of things you can do to reduce the number of app settings, and make them easier to maintain. Each of them has its own positive and negative. Moving them to a db is one, which can help to improve the maintainability ( and can allow you to build a front end to monitor and tweak them without requiring a recycle ). Alternatively, you might want to group some of them into custom sections, if they are related, and so make them better documented, and not just key value pairs.

If they go in the db, you need to consider caching them, and how you should manage the cache.

There is no general answer. It will depend on your situation.


Using an app.config / web.config / database / cache / custom solution to store configuration values are all valid options.

Which method you choose really does depend on what's right for you, your team and your application in your situation.


I would expect that doing this would give you a performance hit as appSettings are loaded into memory what the application is loaded and then reloaded if the web.config is updated. If you stored them in a database then you would need to hit the database everytime.

I couldn't give an indication of the level of performance difference so it may or may not be an issue.


Asp.net has a mechanism for implementing a custom provider for config. I've looked into this for a scenario where multiple servers need the same config, so having a shared config would be good. there was very very little documentation on it.

You also face the issue that web.config files are watched, so any changes prompt the app to restart. With a DB you'd need an alternate mechanism for this, or work around it or just do without.

Far simpler is to define a custom config section.

Simon

0

精彩评论

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

关注公众号