Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic info to WordPress' health check screen #353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions wp-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,23 @@ function wp_redis_get_info() {
'redis_database' => $database,
);
}

if ( defined( 'WP_REDIS_OBJECT_CACHE' )) {
add_filter( 'debug_information', 'wp_redis_add_health_check_info' );
}

function wp_redis_add_health_check_info( $debug_info ) {
$redis_info = wp_redis_get_info() ;
$debug_info['wp_redis'] = array(
'label' => 'Redis Info',
'fields' => array(
'status' => array( 'label' => 'Status', 'value' => $redis_info['status'] . " to " . $redis_info['redis_host'] . ":" . $redis_info['redis_port'] ),
'uptime' => array( 'label' => 'Uptime', 'value' => $redis_info['uptime'] ),
'used_memory' => array( 'label' => 'Used memory', 'value' => $redis_info['used_memory'] ),
'key_count' => array( 'label' => 'Keys', 'value' => $redis_info['key_count'] ),
'hit_rate' => array( 'label' => 'Hit Ratio', 'value' => $redis_info['lifetime_hitrate'] ),
'inst_ops' => array( 'label' => 'Ops/Second', 'value' => $redis_info['instantaneous_ops'] )
)
);
return $debug_info;
}