在文件或数据库中配置? [英] Configuration in a File or a Database?

查看:88
本文介绍了在文件或数据库中配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是真的要问我是否应该使用RDBMS或配置文件100%的应用程序配置,而是什么的配置最好解决每种方法。



例如,我听说最终用户无法更改的任何类型的配置应该在配置文件而不是数据库中。这是准确吗?



(我主要关心的是许多用户的网络应用程序,但没有特定的平台。)



我发现在开发过程中,将配置存储在文件中是非常有益的。是更容易签出文件(web.config,app.config或一些自定义文件),并进行更改,当代码运行时立即提取。在处理存储在数据库中的配置时涉及更多的摩擦。如果您的团队使用单个开发数据库,​​您可以轻松地影响其他团队成员与您的更改,如果您有个别数据库,它需要不止一个最新开始和运行与最新的配置。此外,XML的灵活性使得更加自然地将不仅仅是名称 - 值对的配置存储在文件中,而不是存储在关系数据库中。



是您要在多个应用程序或网站实例之间重用此配置的位置。在我自己的情况下,我们在一个知名的位置有一个单一的配置文件,可以被任何应用程序引用。



至少,这是我们如何存储static 配置,不必由系统在运行时更新。用户设置可能更适合存储在数据库中。


I'm not really asking whether I should use either a RDBMS or config files for 100% of my application configuration, but rather what kind of configuration is best addressed by each method.

For example, I've heard that "any kind of configuration that is not changeable by the end-user" should be in config files rather than the database. Is this accurate? How do you address configuration?

(I'm primarily concerned with many-user web applications here, but no particular platform.)

解决方案

I find that during development it is of great benefit to have configuration stored in a file.

It is far easier to check out a file (web.config, app.config, or some custom file) and make changes that are instantly picked up when the code is run. There is a little more friction involved in working with configuration stored in a database. If your team uses a single development database you could easily impact other team members with your change, and if you have individual databases it takes more than a "get latest" to be up and running with the latest configuration. Also, the flexibility of XML makes it more natural to store configuration that is more than just "name-value" pairs in a file than in a relational DB.

The drawback is where you want to reuse the configuration across multiple apps or web site instances. In my own case, we have a single config file in a well-known location that can be referenced by any application.

At least, this is how we store "static" configuration that does not have to be updated by the system at runtime. User settings are probably more suited to storage in the DB.

这篇关于在文件或数据库中配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆