Caching and performance

Configuration providers cache bound settings for each (type, source) pair where sources are compared by reference. Caching ensures a solid performance level: only the first Get call is somewhat expensive while all the subsequent ones are extremely cheap. The cache is automatically updated when the underlying source issues new data.

provider.Get<MySettings>(); // may block and incurs binding costs

provider.Get<MySettings>(); // instantly returns a cached object

// ... the source issues a data update ...

provider.Get<MySettings>(); // instantly returns the old cached object

// ... the cache is automatically updated in background...

provider.Get<MySettings>(); // instantly returns an updated cached object
circle-info

Due to caching, configuration provider instances should be reused as much as possible. Ideally there should be just one singleton instance in the application.

circle-exclamation
Configuration providerchevron-rightLog settings updateschevron-rightObtain settings from providerchevron-rightObserve settings via providerchevron-right

Last updated

Was this helpful?