PHP Caching - Is it faster to save in database or create a file?

后端 未结 4 1005
情深已故
情深已故 2021-02-06 01:16

I am currently caching dynamically generated PHP pages by saving them to a database with an expiry time field. If the page is requested again, the program checks for a unexpire

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 01:30

    There is not one real answer to your question, it really depends on the number of queries and the cache the database uses in contrast to the time it takes to parse a file. A lot of other factors may take place as well.

    However you can use PHP extensions such as Memcached as Denis suggested. This works even better in combination with a database by using a framework like Doctrine. This makes it easy to manage your data using the database. And serve the actual data in production by caching query results.

提交回复
热议问题