钩子文档

site_status_persistent_object_cache_thresholds

💡 云策文档标注

概述

此过滤器用于调整建议使用持久对象缓存的阈值参数。开发者可以通过修改这些阈值来影响 WordPress 站点健康检查中是否推荐持久对象缓存的判断逻辑。

关键要点

  • 过滤器名称:site_status_persistent_object_cache_thresholds
  • 参数:$thresholds,一个整数数组,键为阈值名称,值为阈值数字
  • 默认阈值包括 alloptions_count、alloptions_bytes、comments_count 等,用于评估站点数据量
  • 相关函数:WP_Site_Health::should_suggest_persistent_object_cache() 使用此过滤器来确定是否建议使用持久对象缓存
  • 引入版本:WordPress 6.1.0

代码示例

$thresholds = apply_filters(
    'site_status_persistent_object_cache_thresholds',
    array(
        'alloptions_count' => 500,
        'alloptions_bytes' => 100000,
        'comments_count'   => 1000,
        'options_count'    => 1000,
        'posts_count'      => 1000,
        'terms_count'      => 1000,
        'users_count'      => 1000,
    )
);

📄 原文内容

Filters the thresholds used to determine whether to suggest the use of a persistent object cache.

Parameters

$thresholdsint[]
The list of threshold numbers keyed by threshold name.

Source

$thresholds = apply_filters(
	'site_status_persistent_object_cache_thresholds',
	array(
		'alloptions_count' => 500,
		'alloptions_bytes' => 100000,
		'comments_count'   => 1000,
		'options_count'    => 1000,
		'posts_count'      => 1000,
		'terms_count'      => 1000,
		'users_count'      => 1000,
	)
);

Changelog

Version Description
6.1.0 Introduced.