A simple PHP cache method using Redis
The caching method described here is relatively simple, the following is the approximate idea :
Example:
A list cache example, because the list data real-time requirements are not high, can be cached for 1 minutes.
Approximate idea:
According to the URL of the request to determine:
1. The requested URL hash is recorded in Redis and the data in Redis is returned directly.
2. After the requested URL hash is not recorded in Redis, the query database (MySQL) is saved to Redis and returned.
URL format: module, controller, Action (action), page
Data format for Redis cache:
are divided into two types:
One is the HTML tag, which is the HTML page that the frame renders.
The other is the JOSN data, which is part of the data required by the AJAX request.
@note
Using PHP for 5 months, this idea was thought out by my colleague (the leader) and recorded
20150809
-
1 floor static reading world
-
Isn't that how Redis is used?