Home > Article > Backend Development > A simple method for php to use redis for caching, php uses redis for caching_PHP tutorial
The caching method introduced here is relatively simple. Here is the general idea:
Example:
A list caching example. Since the real-time requirements of the 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 there is no record in redis after the requested url hashed, query the database (mysql), save it to redis, and return.
url format: module, controller, operation (action), page
Redis cached data format:
is divided into two types:
One is the html tag, which is the html page rendered by the framework.
The other is josn data, which is the data required for ajax requests.
@note
I have been developing using PHP for 5 months. This idea was thought up by my colleague (leader), record it below
20150809