Home  >  Article  >  Database  >  Why redis is suitable for caching

Why redis is suitable for caching

(*-*)浩
(*-*)浩Original
2019-06-17 10:46:492999browse

Redis is an in-memory cache database;

The data model is: key - value, the format used by non-relational databases to store data;

Why redis is suitable for caching

Database cache: (Recommended learning: Redis video tutorial)

The key value of the sql statement, the query result resultSet is the value, when When accessing the same query statement (select * from t_product), as long as it has been queried before, the call cache will directly return the resultSet, saving the time of the database reading disk data.

Persistence layer cache:

Reduces the time to connect to the database; reduces the process of encapsulating resultSet into an object.

Caching of business layer and control layer:

Reduce the call level.

Describe the logic of caching in the business layer:

Query product information

Judge whether the current query has data in the cache

If If there is data, return directly and the current request ends;

If there is no data, query the persistence layer database data, obtain the data storage and cache it for subsequent access;

More Redis related technologies Article, please visit the Introduction to Using Redis Database Tutorial column to learn!

The above is the detailed content of Why redis is suitable for caching. 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