Automattic\WooCommerce\Internal\Api
OpcacheFileExpiry::ensure_scheduled
Schedule the cleanup if it isn't already scheduled.
Called from QueryCache::write_to_opcache() and QueryCache::read_from_opcache() so the cleanup is rescheduled after a feature-disable/re-enable cycle even when every request hits a cached file (no writes).
Method of the class: OpcacheFileExpiry{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = OpcacheFileExpiry::ensure_scheduled(): void;
OpcacheFileExpiry::ensure_scheduled() OpcacheFileExpiry::ensure scheduled code WC 10.9.1
public static function ensure_scheduled(): void {
if ( wp_cache_get( self::SCHEDULED_CACHE_KEY, QueryCache::CACHE_GROUP ) ) {
return;
}
if ( ! function_exists( 'as_has_scheduled_action' ) || ! function_exists( 'as_schedule_single_action' ) ) {
return;
}
if ( ! as_has_scheduled_action( self::ACTION_HOOK, array(), self::ACTION_GROUP ) ) {
as_schedule_single_action( time() + DAY_IN_SECONDS, self::ACTION_HOOK, array(), self::ACTION_GROUP );
}
wp_cache_set( self::SCHEDULED_CACHE_KEY, true, QueryCache::CACHE_GROUP, HOUR_IN_SECONDS );
}