OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Should GetCultureByName be cached #8706

Closed MatteoPiovanelli-Laser closed 1 year ago

MatteoPiovanelli-Laser commented 1 year ago

https://github.com/OrchardCMS/Orchard/blob/bdba35c704bd07b431fae901f0376856c9a743c2/src/Orchard/Localization/Services/DefaultCultureManager.cs#L70

While checking the queries being fired off to the db for #8688 I noticed that for many test pages I had a handful of queries SELECTing a specific CultureRecord, by culture. Checking around the codebase, my assumption is that those are caused by calls to GetCultureByName. It would be trivial to add a layer of cache to prevent those. Same for GetCultureById. Moreover, the signals to manage eviction of that appear to be already in place, and used in the same manager.

My question to the community and especially (@sebastienros and @BenedekFarkas ) is: do you think this is worth it? I don't have a chance right now to measure this.