WC_Cache_Helper::delete_version_transients()public staticWC 2.3.10

Устарела с версии 3.6.0 Adjusted transient usage to include versions within the transient values, making this cleanup obsolete.. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

When the transient version increases, this is used to remove all past transients to avoid filling the DB.

Note; this only works on transients appended with the transient version, and when object caching is not being used.

Метод класса: WC_Cache_Helper{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$result = WC_Cache_Helper::delete_version_transients( $version );
$version(строка)
Version of the transient to remove.
По умолчанию: ''

Список изменений

С версии 2.3.10 Введена.
Устарела с 3.6.0 Adjusted transient usage to include versions within the transient values, making this cleanup obsolete.

Код WC_Cache_Helper::delete_version_transients() WC 8.7.0

public static function delete_version_transients( $version = '' ) {
	if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) {
		global $wpdb;

		$limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 );

		if ( ! $limit ) {
			return;
		}

		$affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // WPCS: cache ok, db call ok.

		// If affected rows is equal to limit, there are more rows to delete. Delete in 30 secs.
		if ( $affected === $limit ) {
			wp_schedule_single_event( time() + 30, 'delete_version_transients', array( $version ) );
		}
	}
}