This is a typical caching usage scenario. Based on the technical solution you use, there are several points that need to be considered clearly:
Since you choose mongodb, your query scenario should try to use one key to obtain the data of the entire document. This kind of query is what mongodb is best at, and theoretically no further optimization is needed.
If in addition to the above situation, you have to query multiple times to get the desired results, you can consider using cache. Now I feel that using Redis is more flexible than Memcached. More specific steps:
(1) For each query, first go to the cache to see if there is already a value
(2) If not, use your query conditions as the key according to certain rules, the query results as the value, store them in the cache and return the results of this query.
(3) If there is, return it directly (according to business needs, cache invalidation control must also be done, such as the validity period or new writes)
"First store the specific content in memcache, and then obtain the corresponding data from memcache through the index value obtained from the database during query;" I don't quite understand this sentence. Should the data be saved in the cache? If the downtime data is not It’s gone.
I don’t know how much business the poster has. Mongodb is a hybrid database. Even Mongodb also has an in-memory database part. Mongodb is not a bad writing bottleneck, so the reading business should be placed in a pure in-memory database like redis. For business, there is no need to go through the trouble. Wouldn’t it be better to save it directly in mongo?
This is a typical caching usage scenario. Based on the technical solution you use, there are several points that need to be considered clearly:
(1) For each query, first go to the cache to see if there is already a value
(2) If not, use your query conditions as the key according to certain rules, the query results as the value, store them in the cache and return the results of this query.
(3) If there is, return it directly (according to business needs, cache invalidation control must also be done, such as the validity period or new writes)
"First store the specific content in memcache, and then obtain the corresponding data from memcache through the index value obtained from the database during query;" I don't quite understand this sentence. Should the data be saved in the cache? If the downtime data is not It’s gone.
I don’t know how much business the poster has. Mongodb is a hybrid database. Even Mongodb also has an in-memory database part. Mongodb is not a bad writing bottleneck, so the reading business should be placed in a pure in-memory database like redis. For business, there is no need to go through the trouble. Wouldn’t it be better to save it directly in mongo?