M
M
Maxim2019-07-15 14:46:38
JavaScript
Maxim, 2019-07-15 14:46:38

Correct Node JS data sync?

There are 2 players, between them there will be an interaction of actions that will update the data of another player (for example, player B will update certain data of player A and vice versa), but since our server is asynchronous, how to synchronize the data so that they do not lose their relevance .
For example, there will be such a situation that the data will be updated after a certain time (timeout), or immediately (but the server is still asynchronous). But, the same data may already be replaced by the next request. How to get out of this situation so that the data (roughly speaking, does not roll back / change) to irrelevant from the next request.
Player A makes a request to player B, the value 1 should be written to the database in the test column.
But player B at that time also hung up a request (simultaneously, suppose) to change the test column to 0.
The actual request, in fact, is needed from player A, but due to the asynchrony of the data, a situation may arise that at the output we will get test = 0.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question