Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacing apc with apcu functions. #1951

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
22 changes: 11 additions & 11 deletions lib/Zend/Cache/Backend/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
}
Expand All @@ -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];
}
Expand All @@ -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);
}
Expand All @@ -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);
}

/**
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand Down