Advertisement
kkarpieszuk

wp check cache size

Jun 11th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. add_action('shutdown', 'check_cache_size');
  2.  
  3. function check_cache_size() {
  4.     global $wp_object_cache;
  5.    
  6.     $stats = array();
  7.     foreach ($wp_object_cache->cache as $group => $cache) {
  8.         $stats[ number_format( strlen( serialize( $cache ) ) / 1024, 2 ) ] = $group;
  9.     }
  10.     krsort($stats);
  11.    
  12.     ?><pre style="margin:10%;"><?php
  13.    
  14.     echo "Total cache size: " . number_format( strlen( serialize( $wp_object_cache->cache ) ) / 1024, 2 ) . "\n";
  15.    
  16.     print_r($stats);
  17.     ?></pre><?php
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement