0

Let's say there are hundreds, or even thousands, of users on your website at the same time.

In the PHP file, there is a file_get_contents() which reads a JSON file and displays that to those users.

I have heard that for some people, it may return a file does not exist if another user is reading the file.

Is this possible through file_get_contents()? Or is it extremely unlikely

fewjio
  • 15
  • 7
  • Does this answer your question? [Does php's file\_get\_contents ignore file locking?](https://stackoverflow.com/questions/49262971/does-phps-file-get-contents-ignore-file-locking) – Petr Hejda Mar 07 '21 at 17:17
  • 1
    @PetrHejda No.. PHP 8 is out also, that's an old question from 3 years ago – fewjio Mar 07 '21 at 17:17
  • Read operations don't set the exclusive lock on the file for other processes (unless you'd specify that locking mode manually). – user1597430 Mar 07 '21 at 17:21
  • 1
    @PetrHejda, your links are irrelevant. – user1597430 Mar 07 '21 at 17:21
  • 3
    You should have no issues with multiple reads, however to reduce i/o operations on a very busy site, I'd recommend looking at in-memory caching e.g. memcache – rjdown Mar 07 '21 at 17:25
  • 1
    @fewjio I agree with your sentiment but as far as I know, voting to close a question doesn't gain you any reputation points. – ADyson Mar 07 '21 at 17:55

0 Answers0