From 22d966b7b9a05029ee6d0512817cf381390fc9f2 Mon Sep 17 00:00:00 2001 From: test Date: Sun, 2 Jan 2022 21:49:37 +0100 Subject: [PATCH] replacing apc with apcu functions. --- app/code/core/Mage/Core/Model/Cache.php | 2 +- lib/Zend/Cache/Backend/Apc.php | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/core/Mage/Core/Model/Cache.php b/app/code/core/Mage/Core/Model/Cache.php index 831dfa4e764..66024fcea99 100644 --- a/app/code/core/Mage/Core/Model/Cache.php +++ b/app/code/core/Mage/Core/Model/Cache.php @@ -190,7 +190,7 @@ protected function _getBackendOptions(array $cacheOptions) } break; case 'apc': - if (extension_loaded('apc') && ini_get('apc.enabled')) { + if (extension_loaded('apcu') && ini_get('apc.enabled')) { $enable2levels = true; $backendType = 'Apc'; } diff --git a/lib/Zend/Cache/Backend/Apc.php b/lib/Zend/Cache/Backend/Apc.php index cc1e76622ed..61888da6133 100644 --- a/lib/Zend/Cache/Backend/Apc.php +++ b/lib/Zend/Cache/Backend/Apc.php @@ -55,7 +55,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba */ public function __construct(array $options = array()) { - if (!extension_loaded('apc')) { + if (!extension_loaded('apcu')) { Zend_Cache::throwException('The apc extension must be loaded for using this backend !'); } parent::__construct($options); @@ -72,7 +72,7 @@ public function __construct(array $options = array()) */ public function load($id, $doNotTestCacheValidity = false) { - $tmp = apc_fetch($id); + $tmp = apcu_fetch($id); if (is_array($tmp)) { return $tmp[0]; } @@ -87,7 +87,7 @@ public function load($id, $doNotTestCacheValidity = false) */ public function test($id) { - $tmp = apc_fetch($id); + $tmp = apcu_fetch($id); if (is_array($tmp)) { return $tmp[1]; } @@ -109,7 +109,7 @@ public function test($id) public function save($data, $id, $tags = array(), $specificLifetime = false) { $lifetime = $this->getLifetime($specificLifetime); - $result = apc_store($id, array($data, time(), $lifetime), $lifetime); + $result = apcu_store($id, array($data, time(), $lifetime), $lifetime); if (count($tags) > 0) { $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); } @@ -124,7 +124,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false) */ public function remove($id) { - return apc_delete($id); + return apcu_delete($id); } /** @@ -146,7 +146,7 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case Zend_Cache::CLEANING_MODE_ALL: - return apc_clear_cache('user'); + return apcu_clear_cache('user'); break; case Zend_Cache::CLEANING_MODE_OLD: $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); @@ -183,12 +183,12 @@ public function isAutomaticCleaningAvailable() */ public function getFillingPercentage() { - $mem = apc_sma_info(true); + $mem = apcu_sma_info(true); $memSize = $mem['num_seg'] * $mem['seg_size']; $memAvailable= $mem['avail_mem']; $memUsed = $memSize - $memAvailable; if ($memSize == 0) { - Zend_Cache::throwException('can\'t get apc memory size'); + Zend_Cache::throwException('can\'t get apcu memory size'); } if ($memUsed > $memSize) { return 100; @@ -278,7 +278,7 @@ public function getIds() */ public function getMetadatas($id) { - $tmp = apc_fetch($id); + $tmp = apcu_fetch($id); if (is_array($tmp)) { $data = $tmp[0]; $mtime = $tmp[1]; @@ -306,7 +306,7 @@ public function getMetadatas($id) */ public function touch($id, $extraLifetime) { - $tmp = apc_fetch($id); + $tmp = apcu_fetch($id); if (is_array($tmp)) { $data = $tmp[0]; $mtime = $tmp[1]; @@ -320,7 +320,7 @@ public function touch($id, $extraLifetime) if ($newLifetime <=0) { return false; } - apc_store($id, array($data, time(), $newLifetime), $newLifetime); + apcu_store($id, array($data, time(), $newLifetime), $newLifetime); return true; } return false;