Does PHP provide an option to keep a file open instead of re-opening whenever the script is started?
My script is called around 500 times per second and can be compared to a counter script, which reads 100 lines from the file status.json, does some ++ or -- or resets some values in the file and writes the result back to the same file.
With 500 read/writes per second, the hdd has no issue yet and is not blocking other parallel scripts that r/w the same file. However, this will happen as soon as the number of calls per second increase significantly.
That's why I'd like to keep this file open for r/w by any PHP instances without locks or delay by reopening or closing again and again within each script.
Any tip for this? Has this been solved well with sqlite? If yes, I can switch to sqlite.
Does PHP provide an option to keep a file open instead of re-opening whenever the script is started?
no.
Has this been solved well with sqlite?
sqlite being the very same file that have to be opened closed as well
You may try some intelligent database that does it's operations mainly in RAM but also dumps it's content to disc periodically for safety. Mongo is an example