Analysis of discuz x 1.5 Cache Mechanism

Source: Internet
Author: User
Tags bbcode

Introduction: This is a detailed page for discuz x 1.5 cache mechanism analysis. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325737 'rolling = 'no'>
We have analyzed the execution process of dzx. It mentioned that DZ will prepare data before calling the template, and the template will get the prepared data after being compiled. This document mainly analyzes whether DZ stores the prepared data. That is, the data cache.

Dzx first obtains the required data from the database, and then calls the memory method in source \ function \ function_core.php to process the cache. The memory method supports three cache Processing Methods: Get, set, RM, and get methods get data from the cache, and set methods Save the data to the cache, the RM method deletes the data in the cache. When dzx obtains data, it first calls the set operation of the memory method to save the data in the memory. What is the stored procedure?

The memory method calls the get set rm method of the discuz_memory (source \ class \ class_core.php file) class. The three methods then call the corresponding methods of the discuz_memcache class, the discuz_memcache class calls the memcache class method again. memcache inherits from memcachepool. I personally think that DZ should use the memcached open-source Cache System in the end, but what I don't understand is that the Get Set and other methods of the memcache and memcachepool classes are not implemented and there is only one empty function. I have never installed memcached on my computer, and I have not figured out what is going on yet.

After being saved to the cache, it is convenient to retrieve it again, for example:

 
$ Ret = memory ('get', 'Forum _ index_page _ '. $ groupid );

next, let's talk about how dzx knows what data to prepare for each request? This is mainly defined in several entry files mentioned above.
the square (ForUM) module is defined in Forum. php.

// This variable stores the data to be initialized in all Forum modules $ modcachelist = array ('index' => array ('announcements', 'onlinelist ', 'forumlink', 'advs _ Index', 'heats ', 'historyposts', 'onlinerecord', 'userstats'), 'forumdisplay' => array ('smils ', 'announcements _ Forum ', 'globalstick', 'forums', 'icons', 'onlinelist', 'forumstick', 'threadtable _ info', 'threadtableids ', 'stamps'), 'viewthread' => array ('smilies ', 'smileytypes', 'forums ',' Usergroups ', 'rank', 'stamps', 'bbcode', 'smils', 'custominfo', 'groupic', 'stamps', 'threadtableids ', 'threadtable _ info'), 'post' => array ('bbcodes _ display', 'bbcode', 'smileycode', 'smilies ', 'smileytypes', 'icons ', 'domainwhitelist'), 'space' => array ('fields _ required', 'fields _ optional', 'minminfo '), 'group' => array ('grouptype '),); // The default mod is index $ mod =! In_array ($ discuz-> var ['mod'], $ modarray )? 'Index': $ discuz-> var ['mod']; define ('curmodule', $ Mod! = 'Redirect '? $ Mod: 'viewthread'); $ cachelist = array (); If (isset ($ modcachelist [curmodule]) {// by default, $ cachelist = $ modcachelist ['index']; $ cachelist = $ modcachelist [curmodule];} if ($ discuz-> var ['mod'] = 'group') {$ _ g ['basescript'] = 'group ';} // during cache initialization, data of all function points listed in $ modcachelist ['index'] is initialized. $ discuz-> cachelist = $ cachelist; $ discuz-> Init ();

The _ init_setting method of discuz_core in source \ class \ class_core.php contains the following sentence:

 
! Empty ($ this-> cachelist) & loadcache ($ this-> cachelist );

This loadcache initializes all the required data listed in $ cachelist. Loadcache will finally call the cachedata method of source \ function \ function_core.php. cachedata will fetch data from the common_syscache table.

But here we only use some system caches. It is unclear how other data is obtained. Continue the study in another day.

Something wrong may be written. Please correct it.

More articles on "discuz x 1.5 Cache Mechanism Analysis"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/325737.html pageno: 13.

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.