Browse Source

Update Concurrency-Check.md

in line 45 I changed the semicolon to a colon, if it's wrong you can revert it bro
pull/12026/head
Hamza Albreem 4 years ago
committed by GitHub
parent
commit
248bc8c50d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      docs/en/Concurrency-Check.md

28
docs/en/Concurrency-Check.md

@ -2,10 +2,10 @@
### Introduction
Concurrency Check (also known as **Concurrency Control**) refers to specific mechanisms used to ensure data consistency in presence of concurrent changes (multiple processes or users access or change the same data in a database at the same time).
Concurrency Check (also known as **Concurrency Control**) refers to specific mechanisms used to ensure data consistency in the presence of concurrent changes (multiple processes, users access or change the same data in a database at the same time).
There are two commonly used concurrency control mechanisms/approaches;
* **Optimistic Concurrency Control**: Optimistic Concurrency Control allows multiple users to attempt to **update** the same record without informing the users that others are also attempting to **update** the record.
There are two commonly used concurrency control mechanisms/approaches:
* **Optimistic Concurrency Control**: Optimistic Concurrency Control allows multiple users to attempt to **update** the same record without informing the users that others are also attempting to **update** it.
* If a user successfully updates the record, the other users need to get the latest changes for the current record to be able to make changes.
* ABP's concurrency check system uses the **Optimistic Concurrency Control**.
@ -25,9 +25,9 @@ public interface IHasConcurrencyStamp
}
```
* It is the base interface for **concurrency control** and has a just simple property named `ConcurrencyStamp`.
* While a new record **creating**, if the entity implements the `IHasConcurrencyStamp` interface, ABP Framework sets a unique value to the **ConcurrencyStamp** property automatically.
* While a record **updating**, ABP Framework compares the **ConcurrencyStamp** property of the entity with the provided **ConcurrencyStamp** value by the user and if the values are matched, updates the **ConcurrencyStamp** property with the new unique value automatically. If there is a mismatch, `AbpDbConcurrencyException` is thrown.
* It is the base interface for **concurrency control** and only has a simple property named `ConcurrencyStamp`.
* While a new record is **creating**, if the entity implements the `IHasConcurrencyStamp` interface, ABP Framework automatically sets a unique value to the **ConcurrencyStamp** property.
* While a record is **updating**, ABP Framework compares the **ConcurrencyStamp** property of the entity with the provided **ConcurrencyStamp** value by the user and if the values match, it automatically updates the **ConcurrencyStamp** property with the new unique value. If there is a mismatch, `AbpDbConcurrencyException` is thrown.
**Example: Applying Concurrency Control for the Book Entity**
@ -42,7 +42,7 @@ public class Book : Entity<Guid>, IHasConcurrencyStamp
}
```
Also, implement your output and update DTO classes from the `IHasConcurrencyStamp` interface:
Also, implement your output and update the DTO classes from the `IHasConcurrencyStamp` interface:
```csharp
public class BookDto : EntityDto<Guid>, IHasConcurrencyStamp
@ -60,7 +60,7 @@ public class UpdateBookDto : IHasConcurrencyStamp
}
```
Set the **ConcurrencyStamp** input value to the entity in the **UpdateAsync** method of your application service, for that purpose you can use the `SetConcurrencyStampIfNotNull` method like as below:
Set the **ConcurrencyStamp** input value to the entity in the **UpdateAsync** method of your application service, for that purpose you can use the `SetConcurrencyStampIfNotNull` method as below:
```csharp
public class BookAppService : ApplicationService, IBookAppService
@ -80,7 +80,7 @@ public class BookAppService : ApplicationService, IBookAppService
}
```
* After that, when multiple users try to update the same record at the same time, concurrency stamp mismatch occurs and `AbpDbConcurrencyException` is thrown.
* After that, when multiple users try to update the same record at the same time, the concurrency stamp mismatch occurs and `AbpDbConcurrencyException` is thrown.
#### Base Classes
@ -102,7 +102,7 @@ public class Book : FullAuditedAggregateRoot<Guid>
}
```
Then, you can implement your output and update DTO classes from the `IHasConcurrencyStamp` interface:
Then, you can implement your output and update the DTO classes from the `IHasConcurrencyStamp` interface:
```csharp
public class BookDto : EntityDto<Guid>, IHasConcurrencyStamp
@ -120,7 +120,7 @@ public class UpdateBookDto : IHasConcurrencyStamp
}
```
Set the **ConcurrencyStamp** input value to the entity in the **UpdateAsync** method of your application service, for that purpose you can use the `SetConcurrencyStampIfNotNull` method like as below:
Set the **ConcurrencyStamp** input value to the entity in the **UpdateAsync** method of your application service, for that purpose you can use the `SetConcurrencyStampIfNotNull` method as below:
```csharp
public class BookAppService : ApplicationService, IBookAppService
@ -140,8 +140,8 @@ public class BookAppService : ApplicationService, IBookAppService
}
```
After that, when multiple users try to update the same record at the same time, concurrency stamp mismatch occurs and `AbpDbConcurrencyException` is thrown. You can either handle the exception manually or let the ABP Framework handle it for you.
After that, when multiple users try to update the same record at the same time, the concurrency stamp mismatch occurs and `AbpDbConcurrencyException` is thrown. You can either handle the exception manually or let the ABP Framework handle it for you.
ABP Framework shows a user-friendly error message like in the image below, if you don't handle the exception manually.
ABP Framework shows a user-friendly error message as in the image below, if you don't handle the exception manually.
![Optimistic Concurrency](./images/optimistic-concurrency.png)
![Optimistic Concurrency](./images/optimistic-concurrency.png)

Loading…
Cancel
Save