Home  >  Q&A  >  body text

php - How to ensure data security when one operation requests multiple services?

An order operation to purchase goods.
To reduce user points at the same time, insert an order.
In the same library, you can add pessimistic locking to the points table to prevent concurrently generated data from being read multiple times.
Now that HTTP is used to request points service and order service, how to use locking? To prevent reducing the points into negative numbers

==================
The items are point services, points services, and order services. The database is also separate. The lock doesn't work

我想大声告诉你我想大声告诉你2677 days ago785

reply all(3)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-25 15:10:18

    Can use transaction mechanism

    reply
    0
  • 迷茫

    迷茫2017-05-25 15:10:18

    Points can be made using redis

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-25 15:10:18

    You have to consider whether there will be concurrency problems. If there are concurrency problems, it is recommended to put queues + things for processing.

    reply
    0
  • Cancelreply