Wordpress global variable wp_object_cache usage

Source: Internet
Author: User

For example, the definition of wp_cache_add:

 

The code is as follows: Copy code
Function wp_cache_add ($ key, $ data, $ group = '', $ expire = 0 ){
Global $ wp_object_cache;
 
Return $ wp_object_cache-> add ($ key, $ data, $ group, (int) $ expire );
}

Where is the wordpress global variable wp_object_cache defined? Wp_object_cache is the instantiation of an object.

The code is as follows: Copy code

/**
* Sets up Object Cache Global and assigns it.
 *
* @ Since 2.0.0
* @ Global WP_Object_Cache $ wp_object_cache WordPress Object Cache
*/
Function wp_cache_init (){
$ GLOBALS ['WP _ object_cache '] = new WP_Object_Cache ();
}

In the wp_cache_init function, the WP_Object_Cache class is instantiated and placed in a Super global variable. Therefore, global $ wp_object_cache is referenced in cache operation functions such as wp_cache_add, wp_cache_get, and wp_cache_delete.

These functions and the WP_Object_Cache class are defined in ../wp-uplodes/cache. php.

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.