Very basic (pseudo code)
Write program: Code:
store_sql() Code:
read_sql() Next it writes one sql line to the file and releases the lock (so the read program can read when it when necessary). The read program attempts to get a lock on the same file. As long as the write-program is writing, it can't get the lock. Once it gets the lock, it reads the whole file and empties it. Next it releases the lock so the write-program can write again. There are some points: If you forget to free the lock, you may end in a situation where one of the two programs does no longer work. The write-program must be a bit more intelligent. In above function, it 'hangs' till it can get the lock; you probably want it to gather more sql statement to write to file. Hope this helps. |
You could also use another mysql table to store the queries :)
|
All times are GMT -5. The time now is 12:56 AM. |