David Godsey wrote:
> I am looking for a way to write a client program that will wake up when
> there is new data in the database, much like replication.
>
> So instead of my client pulling the database on some fixed interval, I
> would like the mysql daemon to push the data to my client when there is
> new data.  I assume this is possible given that it is done with
> replication.  Does anybody have information on how to implement a client
> program like this?
>
> I'm using PHP, but I'm not opposed to using C or C++ for this kind of
> functionality.

James Neff wrote:
> I'm doing something similar now and I just have my clients (a java app)
> periodically check a small table that indicates theres data ready for
> them.  It's a simple "SELECT count(*) ..." that is fairly inexpensive
> and the does this once every 5 seconds.
>
> I don't know if there is a built-in solution for mysql but this gets the
> job done for me.
>
> Let me know if you find a better way to do this.

David Godsey wrote:
That is a good work around, I appreciate the idea.  The optimal would be a
client that listens on the mysql thread the pushes data to the database. But if there is no way to "tap into that thread", the "select count(*)"
would do.

There must be a way to do it though, since it is done with replication.

Except that it isn't. The Master writes to its local binlog. The slave pulls updates from the master periodically. See the manual for all the details <http://dev.mysql.com/doc/refman/4.1/en/replication-intro.html>.

You could write a daemon to run on the mysql server, which would watch for local changes and push them to your client, but that sounds overly complex to me compared to James' solution.

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to