Quite long but using smaller examples

The business logic must receive a readymade entity because when there is no entity with the specifie id we nee to return another HTTP response code and this is the responsibility of the controller. Therefore the entity must be loade in the controller. Loki Locks are use to prevent simultaneous processing. php class Product Repository public function find ByIdint id bool neeLock Product if nee Lock this lock Service lock Product class id var Product product product Product find whereid id one return product.

That is for example Order not

The method lockcon catenates the class name and id and calls the MySQL function GET_LOCKstr timeout documentation . Its a mutex thats how it works. The first process requests a mutex with a specific name the mutex is marke busy. The second one when Thailand Mobile Number List requesting a mutex with the same name will wait until it is free but no longer than specifie in timeout. The mutex requeste by this function is automatically release when the connection to the database is close. But also to block from changes during checks.

There are no examples of explicit release

In the code since in PHP the connection to the database is close after processing the request. If you release it explicitly then this must be done in the controller after calling the service. Earlier it is impossible since the business logic has not yet complete later Thailand Email List there is no point it will only delay other processes that are going to work with this object. Sometimes you can use a SQL statement FOR UPDATE but it only works within a transaction and processing can be long and use network calls or require separate transactions. It is better to block only aggregate roots otherwise it will be difficult to work with. OrderItem. The point is not only to block from simultaneous changes.

Leave a Comment