Answer the question
In order to leave comments, you need to log in
How to add the whole table to the cache?
Tell me, I need to download price lists and recognize car brands and models. Car models are stored in a separate table. How to make it so that when bypassing the price list products, each time you do not refer to the model table, but, for example, put it in the cache and work from there?
Answer the question
In order to leave comments, you need to log in
Create a unique key and put the value there, then update the cache when the price model changes, read about the dependencies.
Usually the mechanism is like this, there is a certain service, we always turn to it, if there is a price in the cache, it gives it back, if not, it takes it from the database - puts it in the cache - gives it to us.
But you must control the relevance of the price yourself or, as I wrote above, use dependencies (but as I understand it, you don’t want extra requests).
1. Cache is not always faster. Cache is different. So if the query is simple, for a selection from 1 table, then probably you should not do anything at all. And if you do - look in the direction of memcache, you can also think about redis
2. probably the bottleneck of your case is the size of the price list, it is large or not known at all. So here the optimization path leads more to breaking down the price analysis into several parts, rather than caching the table. For example, drive it into a service table, then, according to the schedule, pull it with a crown and select and process it in portions. Then the query to the models will be limited only to a number of models and a smaller sample will get into memory. This will give the result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question