: This article mainly introduces a simple php Cache method using redis. if you are interested in the PHP Tutorial, please refer to it. The cache method described here is relatively simple. The following is a rough idea:
Example:
A list cache example can be cached for 1 minute because the real-time requirement of list data is not high.
General Idea:
Determine based on the request url:
1. if there is a record in redis after the request url is hashed, the data in redis is directly returned.
2. if no record is found in redis after the request url is hashed, the database (mysql) is queried, saved to redis, and returned.
Url format: Module, controller, action, page
Redis Cache data format:
There are two types:
One is html tags, that is, html pages rendered by the framework.
The other is josn data, which is the data required by ajax requests.
@ Note
I have been using php for five months. This idea was developed by my colleagues (leaders). record it.
20150809
The above introduces a simple php Cache method using redis, including some content, hope to be helpful to friends who are interested in PHP tutorials.