T
T
The_XXI2019-04-08 22:21:45
PHP
The_XXI, 2019-04-08 22:21:45

How to organize the cache on the site?

All site content is text, users can create posts themselves, comment and like them, you have to make a lot of database queries. Will it be logical to cache all posts from the database (put them in a text file and update, say, once an hour, and make all queries to this file)? Will the cache file take up a lot of space if there are several thousand posts? Maybe it's more logical to cache data somehow differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
plutoject, 2019-04-08
@The_XXI

It would be more logical to cache in memcache, apcu, redis, etc... That is, in RAM, not on disk. Moreover, if you save the cache to a file when reading 10 last records, will you read, relatively speaking, all a few megabytes? make a key-value store. the same redis allows you to do more flexible operations on data, sorting, limit offset, etc.
By the way, rightly configured databases cache query results quite well.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question