private function initAPCSpec() { $this->setName(pht('APC'))->setVersion(phpversion('apc')); if (ini_get('apc.enabled')) { $this->setIsEnabled(true)->setClearCacheCallback('apc_clear_cache'); $mem = apc_sma_info(); $this->setTotalMemory($mem['num_seg'] * $mem['seg_size']); $info = apc_cache_info(); $this->setUsedMemory($info['mem_size']); $write_lock = ini_get('apc.write_lock'); $slam_defense = ini_get('apc.slam_defense'); if (!$write_lock || $slam_defense) { $summary = pht('Adjust APC settings to quiet unnecessary errors.'); $message = pht('Some versions of APC may emit unnecessary errors into the ' . 'error log under the current APC settings. To resolve this, ' . 'enable "%s" and disable "%s" in your PHP configuration.', 'apc.write_lock', 'apc.slam_defense'); $this->newIssue('extension.apc.write-lock')->setShortName(pht('Noisy APC'))->setName(pht('APC Has Noisy Configuration'))->setSummary($summary)->setMessage($message)->addPHPConfig('apc.write_lock')->addPHPConfig('apc.slam_defense'); } $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); $is_stat_enabled = ini_get('apc.stat'); if ($is_stat_enabled && !$is_dev) { $summary = pht('"%s" is currently enabled, but should probably be disabled.', 'apc.stat'); $message = pht('The "%s" setting is currently enabled in your PHP configuration. ' . 'In production mode, "%s" should be disabled. ' . 'This will improve performance slightly.', 'apc.stat', 'apc.stat'); $this->newIssue('extension.apc.stat-enabled')->setShortName(pht('"%s" Enabled', 'apc.stat'))->setName(pht('"%s" Enabled in Production', 'apc.stat'))->setSummary($summary)->setMessage($message)->addPHPConfig('apc.stat')->addPhabricatorConfig('phabricator.developer-mode'); } else { if (!$is_stat_enabled && $is_dev) { $summary = pht('"%s" is currently disabled, but should probably be enabled.', 'apc.stat'); $message = pht('The "%s" setting is currently disabled in your PHP configuration, ' . 'but Phabricator is running in development mode. This option should ' . 'normally be enabled in development so you do not need to restart ' . 'anything after making changes to the code.', 'apc.stat'); $this->newIssue('extension.apc.stat-disabled')->setShortName(pht('"%s" Disabled', 'apc.stat'))->setName(pht('"%s" Disabled in Development', 'apc.stat'))->setSummary($summary)->setMessage($message)->addPHPConfig('apc.stat')->addPhabricatorConfig('phabricator.developer-mode'); } } } else { $this->setIsEnabled(false); $this->raiseEnableAPCIssue(); } }
protected function _checkApc() { if (function_exists('apc_cache_info') && ($cache = @apc_cache_info($cache_mode))) { return true; } return false; }
function index() { /* $usercache = apc_cache_info('user',false); $entrycount = count($usercache['cache_list']); $usercache = $usercache['cache_list']; $cnt=0; foreach($usercache as $i) { @list($label,$key) = explode(":",$i['info'],2); @list($t,$val) = explode("\t",apc_fetch($i['info'])); if ($val<=5) continue; $cnt++; if ($cnt > 1000) break; if ($key && is_scalar($key)) $tmp[$label][$key] = $val.' '.$i['num_hits']; else $tmp['other'][$i['info']] = $val.' '.$i['num_hits']; } $usercache=NULL; foreach($tmp as &$tmp2) { arsort($tmp2); } */ return array('info' => apc_cache_info(), 'sma' => apc_sma_info(true), 'entrycount' => 0); }
/** * Constructor * * Instantiate the APC cache object * * @throws Exception * @return \Pop\Cache\Adapter\Apc */ public function __construct() { if (!function_exists('apc_cache_info')) { throw new Exception('Error: APC is not available.'); } $this->info = apc_cache_info(); }
public function info($type = "user", $limited = false) { if (CACHE_STATUS) { apc_cache_info($type, $limited); } return false; }
public function index($f3) { $f3->set("title", $f3->get("dict.administration")); $f3->set("menuitem", "admin"); if ($f3->get("POST.action") == "clearcache") { \Cache::instance()->reset(); $f3->set("success", "Cache cleared successfully."); } $db = $f3->get("db.instance"); // Gather some stats $result = $db->exec("SELECT COUNT(id) AS `count` FROM user WHERE deleted_date IS NULL AND role != 'group'"); $f3->set("count_user", $result[0]["count"]); $result = $db->exec("SELECT COUNT(id) AS `count` FROM issue WHERE deleted_date IS NULL"); $f3->set("count_issue", $result[0]["count"]); $result = $db->exec("SELECT COUNT(id) AS `count` FROM issue_update"); $f3->set("count_issue_update", $result[0]["count"]); $result = $db->exec("SELECT COUNT(id) AS `count` FROM issue_comment"); $f3->set("count_issue_comment", $result[0]["count"]); $result = $db->exec("SELECT value as version FROM config WHERE attribute = 'version'"); $f3->set("version", $result[0]["version"]); if ($f3->get("CACHE") == "apc") { $f3->set("apc_stats", apc_cache_info("user", true)); } $this->_render("admin/index.html"); }
public function info($type = "user", $limited = FALSE) { if (_cacheStatus) { apc_cache_info($type, $limited); } return FALSE; }
/** * Gets content panel for the Debugbar * * @return string */ public function getPanel() { $panel = ''; # Support for APC if (function_exists('apc_sma_info') && ini_get('apc.enabled')) { $mem = apc_sma_info(); $mem_size = $mem['num_seg'] * $mem['seg_size']; $mem_avail = $mem['avail_mem']; $mem_used = $mem_size - $mem_avail; $cache = apc_cache_info(); $panel .= '<h4>APC ' . phpversion('apc') . ' Enabled</h4>'; $panel .= round($mem_avail / 1024 / 1024, 1) . 'M available, ' . round($mem_used / 1024 / 1024, 1) . 'M used<br />' . $cache['num_entries'] . ' Files cached (' . round($cache['mem_size'] / 1024 / 1024, 1) . 'M)<br />' . $cache['num_hits'] . ' Hits (' . round($cache['num_hits'] * 100 / ($cache['num_hits'] + $cache['num_misses']), 1) . '%)<br />' . $cache['expunges'] . ' Expunges (cache full count)'; } foreach ($this->_cacheBackends as $name => $backend) { $fillingPercentage = $backend->getFillingPercentage(); $ids = $backend->getIds(); # Print full class name, backends might be custom $panel .= '<h4>Cache ' . $name . ' (' . get_class($backend) . ')</h4>'; $panel .= count($ids) . ' Entr' . (count($ids) > 1 ? 'ies' : 'y') . '<br />' . 'Filling Percentage: ' . $backend->getFillingPercentage() . '%<br />'; $cacheSize = 0; foreach ($ids as $id) { # Calculate valid cache size $mem_pre = memory_get_usage(); if ($cached = $backend->load($id)) { $mem_post = memory_get_usage(); $cacheSize += $mem_post - $mem_pre; unset($cached); } } $panel .= 'Valid Cache Size: ' . round($cacheSize / 1024, 1) . 'K'; } return $panel; }
/** * @return Index */ public function onGet() { $cache = PHP_SAPI !== 'cli' ? apc_cache_info('user') : ['num_entries' => 0, 'mem_size' => 0]; $this['apc'] = ['total' => $cache['num_entries'], 'size' => $cache['mem_size']]; // page speed. $this['performance'] = $this->resource->get->uri('app://self/performance')->request(); return $this; }
/** * @return Statistics[] */ public function getStatistics() { if (!$this->safe) { return array(); } $apcInfo = apc_cache_info('user', true); return array('APC' => new Statistics($apcInfo['num_hits'], $apcInfo['num_misses'])); }
/** * Constructor * * Instantiate the APC cache object * * @param int $lifetime * @throws Exception * @return Apc */ public function __construct($lifetime = 0) { parent::__construct($lifetime); if (!function_exists('apc_cache_info')) { throw new Exception('Error: APC is not available.'); } $this->info = apc_cache_info(); }
/** * Retrieves cached information from APC's data store. * * @param string $type - If $type is "user", information about the user cache will be returned. * @param boolean $limited - If $limited is true, the return value will exclude the individual * list of cache entries. This is useful when trying to optimize calls * for statistics gathering. * * @return array of cached data (and meta-data) or false on failure. */ public static function info($type = '', $limited = false) { try { return apc_cache_info($type, $limited); } catch (\RuntimeException $e) { throw new CacheException($e->getMessage()); } }
function apcinfo() { foreach (apc_cache_info() as $k => $v) { if ($k != 'cache_info') { printf("%s: %s\n", $k, $v); } } }
public function __construct() { $this->extension['redis'] = extension_loaded('redis'); $this->extension['memcache'] = extension_loaded('memcache'); $this->extension['apc'] = function_exists('apc_cache_info') && @apc_cache_info(); $this->extension['xcache'] = function_exists('xcache_get'); $this->extension['eaccelerator'] = function_exists('eaccelerator_get'); }
public function __construct() { $this->keys = array(); $cache_info = apc_cache_info('user'); foreach ($cache_info['cache_list'] as $entry) { $this->keys[$entry['info']] = $entry['ttl']; } }
function getIds() { $ci = apc_cache_info('user'); $keys = array(); foreach ($ci['cache_list'] as $entry) { $keys[] = $entry['info']; } return $keys; }
public function __destruct() { return; echo "\n<!--\n"; print_r(apc_cache_info('user')); print_r(apc_cache_info('filehits')); print_r(apc_cache_info()); echo "\n-->\n"; }
/** */ function stats() { if (!$this->is_ready()) { return null; } $info = apc_cache_info(); $sma = apc_sma_info(); return ['hits' => isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'], 'misses' => isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'], 'uptime' => isset($info['start_time']) ? $info['start_time'] : $info['stime'], 'mem_usage' => $info['mem_size'], 'mem_avail' => $sma['avail_mem']]; }
/** * {@inheritdoc} */ public function getIds() { $ci = apc_cache_info('user'); $keys = array(); foreach ($ci['cache_list'] as $entry) { $keys[] = substr($entry['info'], strlen($this->namespace)); } return $keys; }
/** * @return Array */ public function keys() { $info = apc_cache_info('user'); $list = $info['cache_list']; $keys = array(); foreach ($list as $entry) { $keys[] = $entry['info']; } return $keys; }
function driver_stats($option = array()) { $res = array("info" => "", "size" => "", "data" => ""); try { $res['data'] = apc_cache_info("user"); } catch (Exception $e) { $res['data'] = array(); } return $res; }
function memory() { $this->extension['redis'] = extension_loaded('redis'); $this->extension['memcache'] = extension_loaded('memcache'); $this->extension['apc'] = function_exists('apc_cache_info') && apc_cache_info(); $this->extension['xcache'] = function_exists('xcache_get'); $this->extension['eaccelerator'] = function_exists('eaccelerator_get'); $this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo(); $this->init(); }
/** * Flush the cache. */ function flush() { $prefix = INDEX_FILE_LOCATION . ':' . $this->getContext() . ':' . $this->getCacheId(); $info = apc_cache_info('user'); foreach ($info['cache_list'] as $entry) { if (substr($entry['info'], 0, strlen($prefix)) == $prefix) { apc_delete($entry['info']); } } }
function is_file_cached($file) { $info = apc_cache_info(); foreach ($info['cache_list'] as $cache) { if ($cache['filename'] == $file) { return true; } } return false; }
public function clear($prefix = '') { $ns = $this->getNamespace() . $prefix; $cache = apc_cache_info('user'); foreach ($cache['cache_list'] as $entry) { if (strpos($entry['info'], $ns) === 0) { apc_delete($entry['info']); } } return true; }
public function getStatistic() { $result = array(); $cache_user = apc_cache_info('user', 1); $result['version'] = phpversion('apc'); $result['curr_items'] = $cache_user['num_entries']; $result['bytes'] = $cache_user['mem_size']; $mem = apc_sma_info(); $result['limit_maxbytes'] = $mem['avail_mem']; return $result; }
function cs_cache_info() { $form = array(); $info = apc_cache_info('user'); foreach ($info['cache_list'] as $num => $data) { $handle = $data['info'] . ' (' . $num . ')'; $form[$handle] = array('name' => $handle, 'time' => $data['mtime'], 'size' => $data['mem_size']); } ksort($form); return array_values($form); }
/** * @inheritdoc */ public function status() { $cache_info = apc_cache_info(); $sma_info = apc_sma_info(); $status[self::HITS] = isset($cache_info['nhits']) ? $cache_info['nhits'] : 0; $status[self::MISSES] = isset($cache_info['nmisses']) ? $cache_info['nmisses'] : 0; $status[self::START_TIME] = isset($cache_info['stime']) ? $cache_info['stime'] : 0; $status[self::MEMORY_USED] = isset($cache_info['mem_size']) ? $cache_info['mem_size'] : 0; $status[self::MEMORY_LEFT] = isset($sma_info['avail_mem']) ? $sma_info['avail_mem'] : 0; return $status; }
/** * Force garbage collect expired cache data as items are removed only on fetch! */ public function gc() { $allinfo = apc_cache_info('user'); $keys = $allinfo['cache_list']; $secret = $this->_hash; foreach ($keys as $key) { if (strpos($key['info'], $secret . '-cache-')) { apc_fetch($key['info']); } } }
/** * @see wcf\system\cache\source\ICacheSource::clear() */ public function clear($directory, $filepattern) { $pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%') . str_replace('*', '.*', str_replace('.', '\\.', $filepattern)); $apcinfo = apc_cache_info('user'); $cacheList = $apcinfo['cache_list']; foreach ($cacheList as $cache) { if (preg_match('%^' . $pattern . '$%i', $cache['info'])) { apc_delete($cache['info']); } } }