WordPress and multithreading

Is your plugin intended for use by others, or is it only going to be used on servers you control? If the latter, then there might be a few ways to achieve what you want. For instance, the Sync extension. With that, I think you could use a mutex or semaphore to set a flag, which you could then use in your read/write functions.

If you already have memcache available, then that might be a lightweight way to do the same thing, without needing to install a new extension.

Failing that, you might be able to use a db table lock, but that seems really heavy-handed, and I’d worry about the impact on database performance.

Leave a Comment