Skip to Content
Frontlane Studio
All Snippets
PHP Performance November 14, 2024

Throttling Actions Using wp_using_ext_object_cache()

A PHP snippet for Throttling Actions Using wp_using_ext_object_cache().

WordPress PHP

A PHP snippet for Throttling Actions Using wp_using_ext_object_cache().

function maybe_throttle_heavy_action() {
    if (!wp_using_ext_object_cache()) {
        // Perform a lighter action or skip heavy processing.
        error_log('Skipping heavy processing due to lack of external caching.');
    } else {
        // Perform the usual heavy action here.
        error_log('Running heavy processing since caching is enabled.');
    }
}

add_action('wp_loaded', 'maybe_throttle_heavy_action');