1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

With APCu 5+, use apcu_* function to examine cache state

Summary: Ref T9640. APCu 5.0+ (for PHP7) uses `apcu_*` functions instead of `apc_` functions. Test for function existence and call the appropriate functions.

Test Plan: {F2352695}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9640

Differential Revision: https://secure.phabricator.com/D17198
This commit is contained in:
epriestley 2017-01-12 15:38:28 -08:00
parent a2cd3d9a89
commit 7ccc4cea43

View file

@ -79,28 +79,40 @@ final class PhabricatorDataCacheSpec extends PhabricatorCacheSpec {
} }
private function initAPCCommonSpec() { private function initAPCCommonSpec() {
$mem = apc_sma_info();
$this->setTotalMemory($mem['num_seg'] * $mem['seg_size']);
$info = apc_cache_info('user');
$this->setUsedMemory($info['mem_size']);
$this->setEntryCount(count($info['cache_list']));
$cache = $info['cache_list'];
$state = array(); $state = array();
foreach ($cache as $item) {
$info = idx($item, 'info', '<unknown-key>'); if (function_exists('apcu_sma_info')) {
$key = self::getKeyPattern($info); $mem = apcu_sma_info();
if (empty($state[$key])) { $info = apcu_cache_info();
$state[$key] = array( } else if (function_exists('apc_sma_info')) {
'max' => 0, $mem = apc_sma_info();
'total' => 0, $info = apc_cache_info('user');
'count' => 0, } else {
); $mem = null;
}
if ($mem) {
$this->setTotalMemory($mem['num_seg'] * $mem['seg_size']);
$this->setUsedMemory($info['mem_size']);
$this->setEntryCount(count($info['cache_list']));
$cache = $info['cache_list'];
$state = array();
foreach ($cache as $item) {
$info = idx($item, 'info', '<unknown-key>');
$key = self::getKeyPattern($info);
if (empty($state[$key])) {
$state[$key] = array(
'max' => 0,
'total' => 0,
'count' => 0,
);
}
$state[$key]['max'] = max($state[$key]['max'], $item['mem_size']);
$state[$key]['total'] += $item['mem_size'];
$state[$key]['count']++;
} }
$state[$key]['max'] = max($state[$key]['max'], $item['mem_size']);
$state[$key]['total'] += $item['mem_size'];
$state[$key]['count']++;
} }
$this->setCacheSummary($state); $this->setCacheSummary($state);