Watching a table for change in MySQL?

后端 未结 6 1204
不思量自难忘°
不思量自难忘° 2020-12-05 18:23

Is there a better way to watch for new entries in a table besides selecting from it every n ticks of time or something like that?

I have a table that an external pro

6条回答
  •  执念已碎
    2020-12-05 19:15

    Here's what I do: I've got some triggers set up for the table (insert, delete, update) and those triggers increment a counter in another table. My DB access code keeps a local counter and compares it to the returned value, ultimately sending a bool back to the caller, answering the question IsDataCurrent().

    Our programs that use this DB access code either poll or check it on-request and then make the appropriate calls to keep themselves up to date.

    I'm sure there are other ways to solve this. It worked for me pretty well, though.

提交回复
热议问题