Cache rarely cannot be read resulting in read exception
Wruczek opened this issue · 3 comments
Wruczek commented
It seems like it happens randomly without any cause.
007hacky007 commented
Quickly scanning through the code - seems to be happening because you're not using file-locking and thus if you're accessing the file from more scripts running at the same time, you may get partial file because of the race-conditions. file_put_contents
and file_get_contents
are not atomic operations. This may be solved with LOCK_EX
in the file_put_contents
AND using flock around file_get_contents
(or using flock/fopen instead of the file_get_contents altogether).
Wruczek commented
Thank you for your tip! Now that I think about it, it might be the case. I will try to fix the issue by locking the file.
Wruczek commented
Still needs testing to make sure the issue is fixed