Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does WCF deal with things?

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to deal with things in WCF". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to handle things in WCF.

There are three problems with simple transactions.

1) dirty reading: to put it simply, transaction one changes the data at a certain time, and the changed data is read by transaction two, but transaction one finally fails, resulting in data rollback, and transaction two is a victim.

2) non-repeatable reading: the result of each read of the same data is different, that is, non-repeatable reading. For example, transaction one changes the data to be read, which is a non-repeatable read.

3) Phantom reading: it is very simple, for example, transaction one is in the query data, but transaction two inserts a data that meets the query conditions, which leads to the illusion of newly inserted data.

Three explanations of WCF transaction processing problems may be difficult to understand, in fact, to put it simply, dirty reading is reading the data that others are changing, while repeatable reading is changing the data that others are reading, while illusory reading is reading data that others have not had time to insert, change or delete. I think it is much easier to understand in this way. In view of the different problems above, you can set different isolation methods of transactions to prevent problems, which include

1) Any: the isolation level of a component is obtained from the isolation level of the calling component. If the component is the root component, the isolation level is used in Serializable.

2) ReadUncommitted: reads uncommitted data, which maintains a shared lock when reading data to avoid reading modified data, but can be changed before the end of the transaction, resulting in non-repeatable reads or phantom reads.

3) ReadCommitted: read commit data, issue shared locks and allow non-exclusive locking. This method is similar to reading uncommitted data, which seems similar to reading uncommitted data, but with one difference: the read-only lock of a transaction is unlocked when it is moved to the next line, while the write lock is unlocked only after the transaction is completed or aborted, and the transaction waits for all write locks to be unlocked.

4) RepeatableRead: repeatable read, similar to reading submitted data, placing locks on all data used in the query to prevent other users from updating the data. Prevents non-repeatable reads, but phantom rows can still occur. In this way, the read-only lock is not released until the transaction is terminated or aborted.

5) Serializable: prevents updates or inserts before completing the transaction.

From the above description, several isolation methods are difficult to distinguish, WCF transaction processing is very difficult, but remember these more convenient ways to understand isolation

Isolation level

ReadUncommitted

ReadCommitted

RepeatableRead

Serializable

Dirty reading

Yes

No

No

No

Non-repeatable read

Yes

Yes

No

No

Illusory reading

Yes

Yes

Yes

No

It can be seen from the above table that the isolation method is more stringent than the first class except Any. Any comes down in a continuous line, and if it has no inheritance, it will be the strictest Serializable.

Thank you for your reading, the above is the content of "how to deal with WCF". After the study of this article, I believe you have a deeper understanding of how to deal with WCF, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report