Does the CloudConfigurationManager GetSetting method cache?

后端 未结 3 2063
太阳男子
太阳男子 2021-01-04 09:05

Does anyone know if you take a performance hit calling CloudConfigurationManager GetSetting method? Does it reparse the azure file for example or is it cached? Not sure if

相关标签:
3条回答
  • 2021-01-04 09:25

    No, it is not cached, as you suggested you would have to create you own caching for performance improvement.

    0 讨论(0)
  • 2021-01-04 09:36

    The source is available on github.

    If you take a look at the source you can see that it isn't doing any caching, so if you are seeing performance issues you may want to implement your own caching.

    The body of GetSetting shows a simple return:

    value = GetValue("ServiceRuntime", name, GetServiceRuntimeSetting);
    
    if (value == null)
    {
        value = GetValue("ConfigurationManager", name, n => ConfigurationManager.AppSettings[n]);
    }
    
    return value;
    
    0 讨论(0)
  • 2021-01-04 09:38

    The accepted answer might not be correct.

    It's true that CloudConfigurationManager itself does not cache, but that's because it internally delegates to ConfigurationManager or WebConfigurationManager, which do cache values.

    From MSDN:

    For <appSettings> and <connectionStrings>, you use the AppSettings and ConnectionStrings properties. These methods perform read-only operations, use a single cached instance of the configuration, and are multithread aware.

    So that even if you access from CloudConfigurationManager directly, most probably, there would be no IO operation incurred.

    0 讨论(0)
提交回复
热议问题