java code, using mongodb database, business scenarios are several items, which can be purchased at the front desk, and the backend may modify inventory or online and offline goods at the same time. How to design to ensure that dirty data will not be generated. I am a novice, and my idea at present is to write a locking method in the service layer,
public String updateint type String id int sum int status{
synchronized (id.intern()) {
switchtype{
case 1: //type1sum
break;
case 2: //type2sum()status
break;
default:
break;
}
}
}
but this is not very good either. If there is a negative possibility of reducing the number in the background, how do you do it, seniors? I haven"t been working for long and I don"t have any ideas for QAQ
.