函数文档

wp_cache_delete_multiple()

💡 云策文档标注

概述

wp_cache_delete_multiple() 是 WordPress 中用于一次性删除缓存中多个值的函数。它通过调用 WP_Object_Cache::delete_multiple() 实现,适用于批量缓存清理场景。

关键要点

  • 函数签名:wp_cache_delete_multiple( array $keys, $group = '' )
  • 参数:$keys 为必需数组参数,指定要删除的缓存键;$group 为可选字符串参数,用于缓存分组,默认为空
  • 返回值:返回布尔值数组,按键分组,每个值表示删除成功(true)或失败(false)
  • 引入版本:WordPress 6.0.0

代码示例

function wp_cache_delete_multiple( array $keys, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->delete_multiple( $keys, $group );
}

注意事项

  • 该函数依赖于全局 $wp_object_cache 对象,确保缓存系统已正确初始化
  • 返回值数组可用于检查每个键的删除状态,便于错误处理
  • 相关函数包括 WP_Object_Cache::delete_multiple() 和其他缓存清理函数,如 clean_term_cache() 等

📄 原文内容

Deletes multiple values from the cache in one call.

Description

See also

Parameters

$keysarrayrequired
Array of keys under which the cache to deleted.
$groupstringoptional
Where the cache contents are grouped. Default empty.

Return

bool[] Array of return values, grouped by key. Each value is either true on success, or false if the contents were not deleted.

Source

function wp_cache_delete_multiple( array $keys, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->delete_multiple( $keys, $group );
}

Changelog

Version Description
6.0.0 Introduced.