G
G
gachkydxvbgd2017-05-26 20:01:41
symfony
gachkydxvbgd, 2017-05-26 20:01:41

How to implement sql cache?

I want to implement sql fetch caching, how to implement it correctly and then call this cache from anywhere?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fixid, 2017-05-26
@Fixid

Cache at the database level (no need to rewrite anything) or use memcached (you need to change the code)

A
Alexey Pavlov, 2017-05-27
@lexxpavlov

It is better not to load the database with unnecessary work (caching) that can be done elsewhere. Database scaling is more difficult work than code scaling. Therefore, it is better to cache in the code, and not in the DBMS (which, by the way, uses the cache anyway).
It's better to cache the request as early as possible. For example, a query receives 5 queries in the database, it is better to cache all five queries in the database than to have five different caches of each of the queries.
How to make working with the cache more convenient - see another Symfony and Redis answer where to write the logic for getting the cache?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question