php - Mysql calling interface to achieve data synchronization problem
伊谢尔伦
伊谢尔伦 2017-05-16 13:06:33
0
2
761

1. Scenario description:
Now the local database needs to synchronize inventory (field) information with the pharmacy database. The way to achieve this is to call the pharmacy's interface to obtain the inventory of a single drug.
2. Solution:
Scheduled task time, if synchronization occurs every few minutes (for example: 2 minutes), I query the local database to traverse each record and adjust the interface to update each record.
3. Question:
There are tens of thousands of data in the local database. If the operation memory is taken out at the same time, it will definitely explode. Moreover, the synchronization has not been completed in 2 minutes. What should I do if I re-execute it?

It's a bit vague idea, take it in chunks, for example, take 100 items at a time to update. How to design and test to achieve better results?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
洪涛

I don’t quite understand the requirements, so I can only give you a reference:

1. If you have permission to modify the pharmacy database:

直接在药房数据库添加一个触发器,当库存修改的时候,
主动同步到本地(前提是本地要做映射,也就是可以在外面访问)。

2. If you do not have the right to modify the pharmacy database:

其实是不需要,每隔2分钟去同步一次的。本地在展示的时候,比如,
一页展示10个产品,那在取数据时候,数据的库存字段是去药房取,
而其它字段在本地取(远程取来的时候,做一个本地缓存,防止多从访问去远程取多次)

我想大声告诉你

The author first confirms that by calling the inventory of a single drug through the interface, can you check it all in 2 minutes? If so, it is better to use Redis to save such frequent IO operations first, and then make a scheduled task and insert it into the database later.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template