Home > Backend Development > PHP Tutorial > A simple method for php to use redis for caching, php uses redis for caching_PHP tutorial

A simple method for php to use redis for caching, php uses redis for caching_PHP tutorial

WBOY
Release: 2016-07-13 09:44:23
Original
980 people have browsed it

A simple method for PHP to use redis for caching. PHP uses redis for caching

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1048779.htmlTechArticleA simple method for PHP to use redis for caching. PHP uses redis to cache. The caching method introduced here is relatively simple. The following is a general idea: Example: A list caching example, due to...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template