file_exists() is too slow in PHP. Can anyone suggest a faster alternative?

后端 未结 19 1365
迷失自我
迷失自我 2021-02-05 01:18

When displaying images on our website, we check if the file exists with a call to file_exists(). We fall back to a dummy image if the file was missing.

Howe

19条回答
  •  耶瑟儿~
    2021-02-05 01:44

    You could do a cronjob to periodically create a list of images and store them in DB/file/BDB/...

    Every half an hour should be fine, but be sure to create an interface to reset cache in case of file addition/delete.

    And then, it's also easy to run find . -mmin -30 -print0 on the shell and add new files.

提交回复
热议问题