A simple PHP caching method using redis

不言
Release: 2023-03-01 07:04:01
Original
5290 people have browsed it

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.


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