Guidance for calling GetSiteSettingsAsync() in non-async methods #11472
-
I have a few cases where I want to read the site settings in a non-async method. In both cases I have to call I noticed in #9270 that @jtkech mentioned the idea of adding a I should be clear that I am currently calling Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I notice that from @Piedone in on of my recent PRs, but again I see the same things in Localization module, when we load the cultures inside |
Beta Was this translation helpful? Give feedback.
-
Yes, always better to get settings asynchronously (e.g. lazily on demand), but if you want to also use the config option pattern (as we do in some places) you have no choice. We have an action filter that gets site settings, so most of the time we retrieve them from the cache, so no database async I/O and then no problem to get them synchronously. But yes if we use a distributed cache we may still have async I/O, but here much less prone to a dead lock, and about the DI deadlock we did a fix on our side and there is a good chance that it was also fixed in 6.0. |
Beta Was this translation helpful? Give feedback.
Yes, always better to get settings asynchronously (e.g. lazily on demand), but if you want to also use the config option pattern (as we do in some places) you have no choice.
We have an action filter that gets site settings, so most of the time we retrieve them from the cache, so no database async I/O and then no problem to get them synchronously. But yes if we use a distributed cache we may still have async I/O, but here much less prone to a dead lock, and about the DI deadlock we did a fix on our side and there is a good chance that it was also fixed in 6.0.