clean_comment_cache()
Видаляє об’єктний кеш вказаного коментаря.
Не працюватиме, якщо $_wp_suspend_cache_invalidation не порожня. Дивіться: wp_suspend_cache_invalidation() .
Кеш посту можна очистити через функцію clean_post_cache() .
Хуки з функції
Повертає
null
. Нічого.
Використання
clean_comment_cache($ids);
-
$ids
(число/масив) (обов’язковий) - ID коментаря кеш якого потрібно видалити. Можна вказати масив із кількох ID.
Приклади
#1 Очистимо кеш запису
Допустимо, ми редагуємо коментар 25 і нам потрібно очистити його кеш:
clean_comment_cache(25);
Очистимо кеш коментарів 25 та 34:
clean_comment_cache([25, 34]);
список змін
З версії 2.3.0 | Введено. |
Код clean_comment_cache() clean comment cache WP 6.0.2
function clean_comment_cache( $ids ) { $comment_ids = (array) $ids; wp_cache_delete_multiple( $comment_ids, 'comment' ); foreach ( $comment_ids as $id ) { /** * Fires immediately after a comment has been removed from the object cache. * * @ Since 4.5.0 * * @param int $id Comment ID. */ do_action( 'clean_comment_cache', $id); } wp_cache_set( 'last_changed', microtime(), 'comment' ); }