Saturday 21 May 2022

Working with Web Client SDK :: Performance Tips - Part 2

In this blog post I want to share one more tip that you should know when working with Sitecore Content Hub Client SDK, you will see in this post how a small piece of info is making a big difference in your code performance, if you didn't came across  part 1 of Client SDK performance tips, you can check it out here: 



If you went through previous post, then you have a good idea how load configuration works, if you define a load configuration and used it when getting an entity from content hub, then the SDK will only load these properties and relations you specified in your load configuration, nothing else, and that will save you more time while executing the get entity api, good, how about when you read the value of these different properties or relations, what do you use? what should you use? what is the difference? excited, keep reading....

One way of getting a property is using the Get Property Async method like this: 

 

Also, same way you can get property value using Get Property Value Async like this: 



Another way you can get property is using Get Property method like below: 



Same way you can get the value using Get Property Value method as below: 



So what is the difference between these two? 

The first difference is that the Async method doesn't need a load configuration, meaning, regardless if you specified a load entity configuration when getting the entitiy or not, the Async method will load the property or will get you the property value. BUT the downside here, that this method will execute another call to Content Hub and that will cost you some extra time. 


On the other side, when working with the non async method, you would have to specific a load configuration when getting the entity to pre-load your properties and relations, and that will save you time when getting multiple properties or relations as example, BUT if you miss to add a property or a relation to your load configuration that will cause an expectation when executing this method. 

Hopefully this was helpful, please feel from to comment for any questions or suggestions.  

No comments:

Post a Comment