The caching method introduced here is relatively simple. Here is the general idea:
Example:
An example of list caching. Since the real-time requirements of list data are not high, it can be cached for 1 minute.
General idea:
Judge based on the requested URL:
1. If the requested URL is hashed and recorded in redis, the data in redis will be returned directly.
2. If the requested URL has no record in redis after hashing, query the database (mysql), save it to redis, and return.
URL format: module, controller, operation (action), page
redis cached data format:
divided into two types:
One is the html tag, which is the html page rendered by the framework.
The other is josn data, this part is the data required for ajax request.
@note
I have been developing using PHP for 5 months. This idea was thought up by my colleague (leader), record it
20150809
The above introduces a simple PHP caching method using redis, including I hope this will be helpful to friends who are interested in PHP tutorials.