mysql redis difference

a8bec33fb16e471e91f43a85d36c5e71.jpg1. Summary of the difference between .redis and mysql

 

 

(1) Type

 

        In terms of type, mysql is a relational database, and redis is a cache database

 

(2) Functionally

 

       mysql is used to store data persistently to the hard disk, powerful, but slow

 

       Redis is used to store frequently used data in the cache, and the reading speed is fast

 

(3) Demand

 

       Mysql and redis are generally used together because of different requirements.

 

 

 

2. Detailed description

 

1. The database type of mysql and redis

 

mysql is a relational database, which is mainly used to store persistent data. The data is stored in the hard disk, and the reading speed is relatively slow.

 

Redis is NOSQL, that is, a non-relational database, and it is also a cache database, which stores data in the cache. The cache reads fast and can greatly improve operating efficiency, but the storage time is limited.

 

2. The operating mechanism of mysql

 

As a relational database for persistent storage, mysql is relatively weak in that every time a request is made to access the database, there are I/O operations, if the database is accessed repeatedly. First: A lot of time will be spent on repeatedly linking to the database, resulting in too slow operation efficiency; Second: Repeated access to the database will also cause the database load to be too high, so the concept of caching is derived at this time.

 

3. Cache

 

The cache is the buffer (cache) for data exchange. When the browser executes the request, it will first search in the cache, and if it exists, it will get it; otherwise, it will access the database.

 

The advantage of caching is that the reading speed is fast

 

4. redis database

 

The redis database is a cache database used to store frequently used data, thus reducing the number of access to the database and improving operating efficiency.

Guess you like

Origin blog.csdn.net/weixin_57763462/article/details/131565368