Is reading app.config expensive?

前端 未结 5 1790
青春惊慌失措
青春惊慌失措 2020-12-14 07:15

No question I am yet to be hit by any read speed bottleneck. I am asking to know; if reading app.config frequently is a bad programming choice. I have known of database oper

5条回答
  •  再見小時候
    2020-12-14 07:50

    While the values from the app.config are being cached, frequently reading them in a multithreaded scenario may introduce a serious performance hit. If you have to access the config values concurrently, it will be better to use you own caching. You can derive a custom implementation from the AppSettingsBase class.

    In general, wrapping the default config manager into an own implementation will be a good design decision in most cases. It holds you not only safe from changes to your (customer?) config settings names. But also gives you the flexibility to cache those values or get them from any other source which might be/get important.

提交回复
热议问题