DataSettingsManager

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hey

Profiling of several parts of nopCommerce revealed that DataSettingsManager.LoadSettings() being called hundreds of times. LoadSettings opens and parses the Settings.txt file on every call.

Why does DataSettings have a per dependency lifetime? Sure, with this approach you can change DB connection without restart, but is this really needed?

I think this should be refactored to either support some sort of caching (so it doesn't has to access the filesystem on every request) or be at least scoped lifetime if not better singleton lifetime.

Sample code for some sort of caching



/* ... */
public virtual DataSettings LoadSettings(string filePath = null)
{
    if(_settings == null)
    {
        /* Open and parse file */
    }
    return _settings;
}

public virtual void ResetSettings()
{
    _settings = null;
}
/* ... */



Regards
Raphael
6 years ago
Thanks, Raphael! We'll check it - https://github.com/nopSolutions/nopCommerce/issues/2344
6 years ago
Done. Please see this commit for more details
6 years ago
Nice, thanks for this one!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.