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).
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.
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
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
Thanks Matt - I will take on board what you have suggested as well regarding the need for content updates.
is working on a reply...