Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott Meikle 28 posts 228 karma points
    Feb 02, 2021 @ 17:30
    Scott Meikle
    0

    Unit Of Work Serialization?

    Hello,

    I have a question about Units of Work. Given that a Unit of Work is analogous to a database transaction, is each Unit of Work serialized such that when accessed by multiple customers simultaneously, they effectively execute one after the other without interfering with each other?

    For example, I have a Unit of Work at the end of the order process wrapping the charging of the customer's card and the finalization of the order on success. There are some values within the product node that I would like to update after a successful order and my thinking is that I can do this within the Unit of Work to ensure consistency when multiple customers are ordering that same product at the same time (i.e. a second order will see and add to the first orders changes to the product node as the first order will have been guaranteed to have finished).

    I do hope I have been clear :-)

    Kind regards,

    Scott

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Feb 03, 2021 @ 09:32
    Matt Brailsford
    100

    Hi Scott,

    I think I get what you mean.

    Given Vendr's UoW pattern effectively wraps Umbraco's Scopes API, I think what you have outlined should be the case. Opening a Vendr UoW should create an Umbraco Scope and so any updates to Umbraco should also occur within the same unit / transaction.

    On a side note though, I would say, updating properties on a node in this way is a bit of an anti-pattern in Umbraco. Saving content nodes comes with a lot of baggage such as content history and versions as well as a rather big pipeline of events. This has the makings of really slowing down your site and becoming a bottleneck if transactions are required to wait for all other transactions to complete before they can access the relevant resources.

    Generally I would suggest where possible, if those properties could some how be stored in custom database tables, then this will bypass a lot of these problems ensuring your DB isn't filled up with useless content versions and ensuring the content pipelines aren't being constantly executed. This is very much the reason why Vendr's stock property editor saves it's value to a custom DB table rather than constantly updating the product node itself.

    Hope this helps

    Matt

  • Scott Meikle 28 posts 228 karma points
    Feb 03, 2021 @ 09:45
    Scott Meikle
    0

    Thanks Matt - I will take on board what you have suggested as well regarding the need for content updates.

Please Sign in or register to post replies

Write your reply to:

Draft