FredAt Posted January 14, 2008 Share Posted January 14, 2008 I am planning to use PHP with SQLite to do so custom logging for one of my websites. The reccomendation from the folks on the SQLiute forums is that instead of writing directly to the DB I should cache the writes and do them in a batch since this will improve site access. OK - know how I would do that in Windows in a traditional programming language such as C++ or Delphi but I am fairly new to PHP so I need to ensure that I am still barking up the right tree. I can do either write all my SQL to a temporary text file or to a memory map using sh_mop and then run another PHP script to clean up the cache every few seconds/minutes. In both cases, I am suspect I need to do some work to ensure syncronization of reads/writes to my memory map/text file. In Windows I would simply use Windows Event objects. From what I have read thus far PHP does not offer Events. I could use the PHP semaphore functions but this is where I start getting confused. There is information on the net that suggests that sem_acquire will simply return false if the semaphore is in use by another process. But then there is also information that suggests that it will block. In the former case I would have to run a loop along with a usleep statement before writing my SQL or abandoning the effort. If sem_acquire actually blocks things get messier. I would rather abandon an occassional log entry rather than have the process lock because it cannot access a semaphore that has been blocked by another process that failed. I would be much obliged to anyone who could clarify these issues. Quote Link to comment https://forums.phpfreaks.com/topic/85921-semaphores-syncronization/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.