apcu_cache_info(), 'sma' => apcu_sma_info(true) ); } if (ENABLE_OPCACHE) { $opcache = opcache_get_status(true); } if (ENABLE_REALPATH) { $realpath = array(); foreach( realpath_cache_get() as $path => $item ) { $realpath[] = array_merge(array('path' => $path), $item); } $realpathCacheUsed = realpath_cache_size(); $realpathCacheTotal = machine_size(ini_get('realpath_cache_size')); } if (ENABLE_MEMCACHE) { if (extension_loaded('memcached')) { $memcache = new \Memcached(); $memcacheVersion = 'memcached'; $memcache->addServer(MEMCACHE_HOST, MEMCACHE_PORT); if (!empty(MEMCACHE_USER) && !empty(MEMCACHE_PASSWORD)) { $memcacheVersion = 'memcached-bin'; $memcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $memcache->setSaslAuthData(MEMCACHE_USER, MEMCACHE_PASSWORD); } $memcache_stats = $memcache->getStats(); } else if (extension_loaded('memcache')) { // This extension does not support SASL authentication $memcache = new \Memcache(); $memcacheVersion = 'memcache'; $memcache->addServer(MEMCACHE_HOST, MEMCACHE_PORT); $memcache_stats = $memcache->getExtendedStats(); } if( is_action('memcache_clear') ) { $memcache->flush(); redirect('?'); } if( is_action('memcache_delete') && $memcacheVersion == 'memcached' ) { $list = memcache_ref(); $selector = get_selector(); foreach ($list as $key => $item) if (preg_match($selector, $key)) $memcache->delete($key); redirect( '?action=memcache_select&selector=' . $_GET['selector'] ); } if( is_action('memcache_delete') && $memcacheVersion != 'memcached' ) { $memcache->delete($_GET['selector']); redirect( '?action=memcache_view&selector=' . $_GET['selector'] ); } } if (ENABLE_REDIS) { $redis = new Redis(); try { $redis->connect(REDIS_HOST, REDIS_PORT); if (!empty(REDIS_PASSWORD)) $redis->auth(REDIS_PASSWORD); $redis_db = 0; $redis_dbs = $redis->config('GET', 'databases'); $redis_db_select = !is_numeric(REDIS_DATABASE) && !empty($redis_dbs); $redis_memory = $redis->info('memory'); if (!$redis_db_select) $redis_db = REDIS_DATABASE; else if (!empty($_COOKIE['redis_db'])) $redis_db = (int)$_COOKIE['redis_db']; $redis->select($redis_db); } catch(RedisException $ex) { // Failed to connect } if( $redis->isConnected() && is_action('redis_clear') ) { $redis->flushDb(); redirect('?'); } if( $redis->isConnected() && is_action('redis_delete') ) { $list = redis_keys(get_selector()); foreach ($list as $key => $item) $redis->del($key); redirect( '?action=redis_select&selector=' . $_GET['selector'] ); } } function val_to_str($value) { return htmlentities(var_export($value, true)); } function is_action($action) { return isset( $_GET['action'] ) && $_GET['action'] == $action; } function percentage( $a, $b ) { return ( $a / $b ) * 100; } function has_key( $arr, $key1=null, $key2=null, $key3=null ) { if( isset( $arr[$key1] ) ) return $key1; if( isset( $arr[$key2] ) ) return $key2; if( isset( $arr[$key3] ) ) return $key3; return null; } function get_key( $arr, $key1=null, $key2=null, $key3=null ) { $key = has_key($arr, $key1, $key2, $key3 ); if( empty( $key ) ) return null; return $arr[$key]; } function opcache_mem( $key ) { global $opcache; if( $key == 'total' ) return opcache_mem('free') + opcache_mem('used') + opcache_mem('wasted'); if( in_array( $key, array( 'used', 'free', 'wasted' ) ) ) $key = $key . '_memory'; return $opcache['memory_usage'][$key]; } function opcache_stat( $stat ) { global $opcache; return $opcache['opcache_statistics'][$stat]; } function apcu_mem( $key ) { global $apc; if( $key == 'total' ) return $apc['sma']['seg_size']; if( $key == 'free' ) return $apc['sma']['avail_mem']; if( $key == 'used' ) return apcu_mem('total') - apcu_mem('free'); return 0; } function apcu_ref() { global $apc; if( !empty( $apc['cache']['cache_list'] ) ) return current($apc['cache']['cache_list']); return array(); } function memcache_mem( $key ) { global $memcache_stats; if( $key == 'free' ) return memcache_mem('total') - memcache_mem('used'); if( $key == 'total') $key = 'limit_maxbytes'; if( $key == 'used' ) $key = 'bytes'; if( $key == 'hash' ) $key = 'hash_bytes'; if (!is_array($memcache_stats)) return 0; $result = 0; foreach( $memcache_stats as $server ) $result += empty($server[$key]) ? 0 : $server[$key]; return $result; } function memcache_get_key($key, &$found = false) { global $memcache; global $memcacheVersion; if (empty($key)) { $found = false; return false; } if ($memcacheVersion == 'memcache') { $val = $memcache->get(array($key)); $found = count($val) > 0; return $found ? array_pop($val) : false; } $val = $memcache->get($key, null, Memcached::GET_EXTENDED); $found = $val !== false; return $val['value']; } function memcache_ref() { global $memcache; global $memcacheVersion; // Listing keys is not supported using the legacy Memcache module // PHP 7 and newer do not support this extension anymore if ($memcacheVersion != 'memcached') return array(); $items = $memcache->getAllKeys(); if (!is_array($items)) return array(); $keys = array(); foreach( $items as $item ) { $keys[$item] = memcache_get_key($item); } return $keys; } function redis_mem( $key ) { global $redis_memory; if( $key == 'free' ) return max(redis_mem('total') - redis_mem('used'), 0); if( $key == 'total' && !empty($redis_memory['maxmemory']) ) return $redis_memory['maxmemory']; if( $key == 'total' && !empty($redis_memory['total_system_memory']) ) return $redis_memory['total_system_memory']; if( $key == 'total' && !empty(REDIS_SIZE)) return (int)REDIS_SIZE; if( $key == 'total') return redis_mem('used'); if ($key == 'used') return $redis_memory['used_memory']; if ($key == 'overhead' && !empty($redis_memory['used_memory_overhead'])) return $redis_memory['used_memory_overhead']; return 0; } function redis_get_key($key, &$found = false) { global $redis; $type = $redis->type($key); $found = $redis->exists($key); $value = null; if ($type == Redis::REDIS_STRING || $type == Redis::REDIS_NOT_FOUND) $value = $redis->get($key); else if ($type == Redis::REDIS_HASH) $value == $redis->hgetall($key); else if ($type == Redis::REDIS_LIST) $value = $redis->lrange(0, -1); else if ($type == Redis::REDIS_SET || $type == Redis::REDIS_ZSET) { $it = null; $value = array(); do { $res = $redis->sscan($key, $it); if (!is_array($res)) continue; $value = array_merge($value, $res); } while ($it > 0); } else if ($type == Redis::REDIS_ZSET) { $len = $redis->zcard($key); $start = 0; $value = array(); while($start < $len) { $stop = $start + 99; $res = $redis->zrange($key, $start, $stop, true); $start += 100; } } return $value; } function redis_keys($selector) { global $redis; $keys = array(); $it = null; do { $res = $redis->scan($it); if (!is_array($res)) continue; foreach ($res as $key) { if (!preg_match($selector, $key)) continue; $keys[$key] = array( 'key' => $key, 'ttl' => $redis->ttl($key), 'type' => $redis->type($key), 'size' => $redis->rawCommand('memory', 'usage', $key) ); } } while($it > 0); return $keys; } function human_size( $s ) { $size = 'B'; $sizes = array( 'KB', 'MB', 'GB' ); while( $s > 1024 ) { $size = array_shift( $sizes ); $s /= 1024; } $s = round( $s, 2 ); return $s . ' ' . $size; } function machine_size( $val ) { $val = trim($val); $last = strtolower($val[strlen($val)-1]); if (!is_numeric($last)){ $val = (int) substr($val, 0, -1); } if ($last == 'g') $val *= (1024 * 1024 * 1024); if ($last == 'm') $val *= (1024 * 1024); if ($last == 'k') $val *= 1024; return $val; } function redirect($url) { header('Status: 302 Moved Temporarily'); header('Location: '. $url); exit(); } function get_selector() { return '#' . str_replace( '#', '\#', urldecode($_GET['selector']) ) . '#'; } function sort_url($on) { $query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY); if( empty( $query ) ) $query = ''; else $query .= '&'; $query = preg_replace( '#sort=[^&]+&?#', '', $query ); $query = preg_replace( '#order=[^&]+&?#', '', $query ); if( !isset( $_GET['order'] ) ) $_GET['order'] = ''; $query .= 'sort=' . urlencode($on); $query .= '&order=' . ( $_GET['order'] == 'asc' ? 'desc' : 'asc' ); return '?' . $query; } function sort_list($list) { if( !isset( $_GET['sort'] ) ) return $list; $key = urldecode($_GET['sort']); $reverse = isset($_GET['order']) ? ( urldecode($_GET['order']) == 'desc' ) : false; usort($list, function( $item1, $item2 ) use ( $key, $reverse ) { if( $reverse ) { $tmp = $item1; $item1 = $item2; $item2 = $tmp; unset($tmp); } if( is_string( $item1[$key] ) || is_string( $item2[$key] ) ) return strcmp( $item1[$key], $item2[$key] ); return $item1[$key] - $item2[$key]; }); return $list; } /********************************/ /* OPcache */ /********************************/ if (ENABLE_OPCACHE) { if( is_action('op_restart') ) { opcache_reset(); redirect('?'); } if( is_action('op_delete') ) { $selector = get_selector(); foreach( $opcache['scripts'] as $key => $value ) { if( !preg_match( $selector, $key) ) continue; opcache_invalidate( $key, empty($_GET['force'])?false:true ); } redirect('?action=op_select&selector=' . $_GET['selector'] ); } } /********************************/ /* APC */ /********************************/ if (ENABLE_APC) { if( is_action('apcu_restart') ) { apcu_delete( new ApcuIterator('#.*#') ); redirect('?'); } if( is_action('apcu_delete') ) { apcu_delete( new ApcuIterator(get_selector()) ); redirect( '?action=apcu_select&selector=' . $_GET['selector'] ); } } /********************************/ /* realpath */ /********************************/ if (ENABLE_REALPATH) { if( is_action('realpath_clear') ) { clearstatcache(true); redirect('?action=realpath_show#realpath'); } if( is_action('realpath_delete') ) { $selector = get_selector(); foreach( $realpath as $item ) { if( !preg_match( $selector, $item['path']) ) continue; clearstatcache(true, $item['path']); } redirect('?action=realpath_show&selector=' . $_GET['selector'] . '#realpath'); } } ?> Cache Status
Goto: PHP Opcache' : null, ENABLE_APC ? '' . $apcVersion . '' : null, ENABLE_REALPATH ? 'Realpath' : null ))) ?>

PHP Opcache

Memory of

Keys of

Cache hit %

Actions

Keys matching

Key Hits Size Action
Delete Force Delete

Memory of

Actions

Value for

Keys matching

0 && get_key($item, 'mtime', 'modification_time') + $item['ttl'] < time(); if( !preg_match(get_selector(), get_key($item, 'key', 'info')) || $expired ) continue;?>
Key Hits Size TTL Expires Action
Delete View

Realpath

Memory of

Actions

Path Is Directory Realpath Expires Key

Memcached

Memory of

Actions

Value for

Key not found

$value ): if( !preg_match(get_selector(), $key) ) continue;?>
Key Action
Delete View

When SASL authentication is enabled on the memcached extension we can not support listing keys

Legacy memcache extension does not support listing keys
Please install the newer memcached extension

isConnected()): ?>

Redis

Memory of

Actions

Value for

Key not found

$item ):?>
Key Size TTL Expires Action
Delete View