wp_start_object_cache()
- Since
- 3.0.0
- Source
wp-includes/load.php:833
Description
If an object-cache.php file exists in the wp-content directory, it uses that drop-in as an external object cache.
Compatibility
- WordPress
- since 3.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to wp_start_object_cache() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 22–70
- Plugin surface
- 1 hook
- Called by
- 0
Reads or writes the filesystem via file_exists().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 88.
Third-party callbacks on 'enable_loading_object_cache_dropin' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_switch_to_blog()called directly - filesystemfilesystem access
file_exists()called directly
What one call costs · 100 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_start_object_cache() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!function_exists() | 22–27 | wp_using_ext_object_cache(), function_exists(), function_exists() |
| always | 24–29 | wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
!function_exists() | 26–31 | wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
!apply_filters() && !function_exists() | 27–32 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists() |
| always | 28–33 | wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
| always | 28–33 | wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
| always | 28–33 | wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
!apply_filters() | 29–34 | apply_filters(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
function_exists() | 30–35 | wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
!apply_filters() && !function_exists() | 31–36 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
| always | 32–37 | wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
!apply_filters() | 33–38 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
88 further outcomes, up to 70 instructions
!apply_filters() | 33–38 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
!apply_filters() | 33–38 | apply_filters(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && wp_using_ext_object_cache() | 34–39 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists() |
| always | 34–39 | wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
function_exists() | 34–39 | wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
!apply_filters() && function_exists() | 35–40 | apply_filters(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && wp_using_ext_object_cache() | 36–41 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !function_exists() && !file_exists() | 37–42 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists() |
!apply_filters() | 37–42 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && wp_using_ext_object_cache() | 38–43 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && !file_exists() | 39–44 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
!apply_filters() | 39–44 | apply_filters(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
!apply_filters() && function_exists() | 39–44 | apply_filters(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 40–45 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && wp_using_ext_object_cache() | 40–45 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && wp_using_ext_object_cache() | 40–45 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && wp_using_ext_object_cache() | 40–45 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && !function_exists() && !file_exists() | 41–46 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 42–47 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && function_exists() && wp_using_ext_object_cache() | 42–47 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 43–48 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && !file_exists() | 43–48 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !file_exists() | 43–48 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !file_exists() | 43–48 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 44–49 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && wp_using_ext_object_cache() | 44–49 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !function_exists() && file_exists() | 45–50 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 45–50 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !file_exists() | 45–50 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 46–51 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 46–51 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 46–51 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && wp_using_ext_object_cache() | 46–51 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && function_exists() && wp_using_ext_object_cache() | 46–51 | apply_filters(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 47–52 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 47–52 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && !file_exists() | 47–52 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 48–53 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && function_exists() && !wp_using_ext_object_cache() && !file_exists() | 48–53 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !function_exists() && file_exists() | 49–54 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 49–54 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 49–54 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 49–54 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && !file_exists() | 49–54 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !file_exists() | 49–54 | apply_filters(), function_exists(), file_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !function_exists() && file_exists() | 50–55 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && file_exists() | 50–55 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 50–55 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 51–56 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 51–56 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && file_exists() | 51–56 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && function_exists() && !wp_using_ext_object_cache() && file_exists() | 51–56 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 52–57 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && file_exists() | 52–57 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && !file_exists() | 52–57 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && function_exists() && !wp_using_ext_object_cache() && !file_exists() | 52–57 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 53–58 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists() |
apply_filters() && file_exists() | 53–58 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 53–58 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && !function_exists() && file_exists() | 54–59 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && file_exists() | 54–59 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 54–59 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && file_exists() | 54–59 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && file_exists() | 55–60 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 55–60 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && !wp_using_ext_object_cache() && file_exists() | 55–60 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && function_exists() && !wp_using_ext_object_cache() && file_exists() | 55–60 | apply_filters(), function_exists(), wp_using_ext_object_cache(), file_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 56–61 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 56–61 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && file_exists() | 56–61 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && file_exists() | 56–61 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 57–62 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists() |
apply_filters() && file_exists() | 57–62 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 57–62 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 58–63 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 58–63 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 59–64 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 59–64 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists() |
apply_filters() && file_exists() | 59–64 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists() |
apply_filters() && file_exists() | 60–65 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 60–65 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 60–65 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 61–66 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 62–67 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 62–67 | apply_filters(), function_exists(), file_exists(), function_exists(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 63–68 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 65–70 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), function_exists(), wp_cache_init(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
apply_filters() && file_exists() | 65–70 | apply_filters(), function_exists(), file_exists(), function_exists(), wp_using_ext_object_cache(), ::WP_Hook(), wp_using_ext_object_cache(), function_exists(), get_current_blog_id(), wp_cache_switch_to_blog(), function_exists(), wp_cache_add_global_groups(), wp_cache_add_non_persistent_groups() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 88 instructions, 22–70 executed per call, 13 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while wp_start_object_cache() runs, in this order:
- apply_filters( enable_loading_object_cache_dropin )filterline 850 (+17 into the body)
Filters whether to enable loading of the object-cache.php drop-in.
Uses · 8
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_using_ext_object_cache()Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.
- wp_cache_switch_to_blog()Used when switch_to_blog() and restore_current_blog() are called, but only when a persistent object cache drop-in plugin has omitted the wp_cache_switch_to_blog() function that was introduced in 3.5.0.
- get_current_blog_id()Retrieves the current site ID.
- wp_cache_init()Sets up Object Cache Global and assigns it.
- wp_cache_add_global_groups()Adds a group or set of groups to the list of global groups.
- wp_cache_add_non_persistent_groups()Adds a group or set of groups to the list of non-persistent groups.
- WP_Hook::build_preinitialized_hooks()Normalizes filters set up before WordPress has initialized to WP_Hook objects.
Source code
function wp_start_object_cache() { global $wp_filter; static $first_init = true; // Only perform the following checks once. /** * Filters whether to enable loading of the object-cache.php drop-in. * * This filter runs before it can be used by plugins. It is designed for non-web * runtimes. If false is returned, object-cache.php will never be loaded. * * @since 5.8.0 * * @param bool $enable_object_cache Whether to enable loading object-cache.php (if present). * Default true. */ if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { if ( ! function_exists( 'wp_cache_init' ) ) { /* * This is the normal situation. First-run of this function. No * caching backend has been loaded. * * We try to load a custom caching backend, and then, if it * results in a wp_cache_init() function existing, we note * that an external object cache is being used. */ if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { require_once WP_CONTENT_DIR . '/object-cache.php'; if ( function_exists( 'wp_cache_init' ) ) { wp_using_ext_object_cache( true ); } // Re-initialize any hooks added manually by object-cache.php. if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } } } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { /* * Sometimes advanced-cache.php can load object-cache.php before * this function is run. This breaks the function_exists() check * above and can result in wp_using_ext_object_cache() returning * false when actually an external cache is in use. */ wp_using_ext_object_cache( true ); } } if ( ! wp_using_ext_object_cache() ) { require_once ABSPATH . WPINC . '/cache.php'; } require_once ABSPATH . WPINC . '/cache-compat.php'; /* * If cache supports reset, reset instead of init if already * initialized. Reset signals to the cache that global IDs * have changed and it may need to update keys and cleanup caches. */ if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( get_current_blog_id() ); } elseif ( function_exists( 'wp_cache_init' ) ) { wp_cache_init(); } if ( function_exists( 'wp_cache_add_global_groups' ) ) { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'image_editor', 'networks', 'network-queries', 'sites', 'site-details',Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/load.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.