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.