The answers below are all based on the large amount of data in the main table.
Method 1
(1) Use mysql trigger
(2) mysql can run external scripts (may be related to user permissions and platform), and trigger back-end programs through scripts
Method 2
(1) Use mysql trigger
(2) After triggering the data, write the data to the memory table
(3) The back-end program polls the memory table. After the processing is completed, the polled data is deleted to prevent the memory table from exploding
The best solution to your idea should be Hook to make a hook for MySQL and execute the hook program when the database changes. However, after searching, there seems to be no good ideas for directly adding Hooks to the database.
The only feasible way is to use Git to manage your MySQL database, and call Hook through Git when the database file changes. Although it is feasible, it feels a little geeky.
So it seems that the simpler idea is to think from your program. When the program executes the insert() function in the database operation class, it executes a certain Hook函数. That is to say, do not add hooks to the database, but add hooks to the database operation class of the program.
The answers below are all based on the large amount of data in the main table.
Method 1
(1) Use mysql trigger
(2) mysql can run external scripts (may be related to user permissions and platform), and trigger back-end programs through scripts
Method 2
(1) Use mysql trigger
(2) After triggering the data, write the data to the memory table
(3) The back-end program polls the memory table. After the processing is completed, the polled data is deleted to prevent the memory table from exploding
The best solution to your idea should be
Hook
to make a hook for MySQL and execute the hook program when the database changes. However, after searching, there seems to be no good ideas for directly adding Hooks to the database.The only feasible way is to use Git to manage your MySQL database, and call Hook through Git when the database file changes. Although it is feasible, it feels a little geeky.
So it seems that the simpler idea is to think from your program. When the program executes the
insert()
function in the database operation class, it executes a certainHook函数
. That is to say, do not add hooks to the database, but add hooks to the database operation class of the program.触发器
Can it meet your needs? ?Triggered when insert is executed. .