I’m writing a small program that does just one task, stores phone numbers that need to be returned,
And my goal is to use a single Json file as the database. Now here is my problem, since I want all employees to have access to this program I can’t use PHP’s json_decode and _encode functions and then use fwrite() because then one employee will be overriding another. So my question is if their is any workaround for this or if someone can suggest a library that would handle this.
Any help is appreciated.
I’m writing a small program that does just one task, stores phone numbers that
Share
You can handle this by creating a mutex. If you’re on Windows, I’d suggest flock, but if you’re on *nix, I’d suggest a sys5 semaphore.
As an aside, if you want a much hackier/simpler setup, you can pump the output from
json_encodethrough error_log, as it implements its own mutex.Another option which is probably easier would be to use SQLite.