Home >Database >Redis >Which data should be placed in redis and which should be placed in the database?

Which data should be placed in redis and which should be placed in the database?

(*-*)浩
(*-*)浩Original
2019-11-30 09:58:484805browse

Which data should be placed in redis and which should be placed in the database?

When using redis as cache, does the data still need to be stored in the database? (Recommended learning: Redis video tutorial)

Which data should be placed in redis and which should be placed in the database?My answer is:

redis is just caching, It is not a database such as mysql, so the databases in redis must be in mysql.

User request first requests redis, if not, then reads it from the database.

Some data with relatively large request volume is cached in redis (these cached data must also be available in mysql). It is not necessary to cache all data in redis.

The reason why it is faster to get data from the cache is because the cached data exists in the memory, unlike mysql data which is stored on the disk, that is, there is no need to load it from the disk to This process of memory (this process is very time-consuming and inefficient), obtains data directly from memory.

When the redis cache crashes, don't a massive number of requests access the database? Can the database survive?

Accept it and analyze it. If hundreds of billions of requests are accessed at the same time, why can’t the database handle it?

①The database cannot handle the huge amount of concurrency.

You will understand with an example.

100 million plsql clients, accessing Oracle at the same time for database query, write and other operations, will definitely be overwhelming for the database.

From this perspective, redis can't help much.

②The database exists on a low-speed device. Every time you access the database, you have to go through io, which is the process of transferring from disk to memory. This is the reason for using caching mechanisms such as redis.

For more Redis-related technical articles, please visit the Redis Getting Started Tutorial column to learn!

The above is the detailed content of Which data should be placed in redis and which should be placed in the database?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn