callumbwhyte / super-value-converters

A collection of powerful property value converters for cleaner code in Umbraco
MIT License
14 stars 12 forks source link

DataTypeHelper hitting database? #4

Closed enkelmedia closed 3 years ago

enkelmedia commented 5 years ago

Hi man!

Great project! I've found my self getting annoyed by this many times but never got the idea to sit down and create something to "get around" it. So I love the initiative!

Without having tested this, I just have one question, in the converters you are using the DataTypeHelper which uses the DataTypeService "under the hoods". Do you know if this is hitting the database to fetch the prevalues? I know that is used to do but maybe there has been a cache added or something? If it's hitting the database this will be quite a performance bottleneck.

Example: https://github.com/callumbwhyte/super-value-converters/blob/dev/src/Our.Umbraco.SuperValueConverters/Helpers/DataTypeHelper.cs

I really look forward to try this out!

All the best!

callumbwhyte commented 5 years ago

Hey @enkelmedia!

Thanks for your interest in SuperValueConverters! šŸ‘

Your question about DB hits is a valid one... Iā€™m not entirely sure if the DataTypeService has a cache, but I presume it still hits the DB directly.

Prevalues are only fetched when the GetPropertyValueType is called in order to evaluate what type to return - this is called on app start or when Models Builder regenerates - and so there are no database hits when simply ā€œconvertingā€ a value. Given the (usually) relatively small number of data types and properties in a site I donā€™t expect this bottleneck to be too big...

That said, thereā€™s probably a bit of caching that could be added to avoid duplicate lookups - I need to do this for the type finder code too. Iā€™ve put a card into my next ā€œreleaseā€ to investigate this: https://github.com/callumbwhyte/super-value-converters/projects/1#card-17320166

Let me know if you have any questions or feedback once you give the package a try! šŸ˜Ž

Cheers, Callum

callumbwhyte commented 3 years ago

Closing this as it's no longer relevant in Umbraco 8.