A simple php Cache method using redis

Source: Internet
Author: User
: This article mainly introduces a simple php Cache method using redis. if you are interested in the PHP Tutorial, please refer to it. The cache method described here is relatively simple. The following is a rough idea:
Example:
A list cache example can be cached for 1 minute because the real-time requirement of list data is not high.


General Idea:
Determine based on the request url:
1. if there is a record in redis after the request url is hashed, the data in redis is directly returned.
2. if no record is found in redis after the request url is hashed, the database (mysql) is queried, saved to redis, and returned.
Url format: Module, controller, action, page


Redis Cache data format:
There are two types:
One is html tags, that is, html pages rendered by the framework.
The other is josn data, which is the data required by ajax requests.

@ Note

I have been using php for five months. This idea was developed by my colleagues (leaders). record it.

20150809

The above introduces a simple php Cache method using redis, including some content, hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.