WP_Object_Cache::stats() WordPress Method

The WP_Object_Cache::stats() method is used to retrieve the current status of the object cache. This can be useful for debugging purposes or for monitoring the performance of the cache.

WP_Object_Cache::stats() #

Echoes the stats of the caching.


Description

Gives the cache hits, and cache misses. Also prints every cached group, key and the data.


Top ↑

Source

File: wp-includes/class-wp-object-cache.php

	public function stats() {
		echo '<p>';
		echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
		echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
		echo '</p>';
		echo '<ul>';
		foreach ( $this->cache as $group => $cache ) {
			echo '<li><strong>Group:</strong> ' . esc_html( $group ) . ' - ( ' . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
		}
		echo '</ul>';
	}


Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.