Skip to content

Commit a978a51

Browse files
Replace APC with APCu (#1951)
1 parent 362582b commit a978a51

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

app/code/core/Mage/Core/Model/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected function _getBackendOptions(array $cacheOptions)
190190
}
191191
break;
192192
case 'apc':
193-
if (extension_loaded('apc') && ini_get('apc.enabled')) {
193+
if (extension_loaded('apcu') && ini_get('apc.enabled')) {
194194
$enable2levels = true;
195195
$backendType = 'Apc';
196196
}

lib/Zend/Cache/Backend/Apc.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
5555
*/
5656
public function __construct(array $options = array())
5757
{
58-
if (!extension_loaded('apc')) {
58+
if (!extension_loaded('apcu')) {
5959
Zend_Cache::throwException('The apc extension must be loaded for using this backend !');
6060
}
6161
parent::__construct($options);
@@ -72,7 +72,7 @@ public function __construct(array $options = array())
7272
*/
7373
public function load($id, $doNotTestCacheValidity = false)
7474
{
75-
$tmp = apc_fetch($id);
75+
$tmp = apcu_fetch($id);
7676
if (is_array($tmp)) {
7777
return $tmp[0];
7878
}
@@ -87,7 +87,7 @@ public function load($id, $doNotTestCacheValidity = false)
8787
*/
8888
public function test($id)
8989
{
90-
$tmp = apc_fetch($id);
90+
$tmp = apcu_fetch($id);
9191
if (is_array($tmp)) {
9292
return $tmp[1];
9393
}
@@ -109,7 +109,7 @@ public function test($id)
109109
public function save($data, $id, $tags = array(), $specificLifetime = false)
110110
{
111111
$lifetime = $this->getLifetime($specificLifetime);
112-
$result = apc_store($id, array($data, time(), $lifetime), $lifetime);
112+
$result = apcu_store($id, array($data, time(), $lifetime), $lifetime);
113113
if (count($tags) > 0) {
114114
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
115115
}
@@ -124,7 +124,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
124124
*/
125125
public function remove($id)
126126
{
127-
return apc_delete($id);
127+
return apcu_delete($id);
128128
}
129129

130130
/**
@@ -146,7 +146,7 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
146146
{
147147
switch ($mode) {
148148
case Zend_Cache::CLEANING_MODE_ALL:
149-
return apc_clear_cache('user');
149+
return apcu_clear_cache('user');
150150
break;
151151
case Zend_Cache::CLEANING_MODE_OLD:
152152
$this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend");
@@ -183,12 +183,12 @@ public function isAutomaticCleaningAvailable()
183183
*/
184184
public function getFillingPercentage()
185185
{
186-
$mem = apc_sma_info(true);
186+
$mem = apcu_sma_info(true);
187187
$memSize = $mem['num_seg'] * $mem['seg_size'];
188188
$memAvailable= $mem['avail_mem'];
189189
$memUsed = $memSize - $memAvailable;
190190
if ($memSize == 0) {
191-
Zend_Cache::throwException('can\'t get apc memory size');
191+
Zend_Cache::throwException('can\'t get apcu memory size');
192192
}
193193
if ($memUsed > $memSize) {
194194
return 100;
@@ -278,7 +278,7 @@ public function getIds()
278278
*/
279279
public function getMetadatas($id)
280280
{
281-
$tmp = apc_fetch($id);
281+
$tmp = apcu_fetch($id);
282282
if (is_array($tmp)) {
283283
$data = $tmp[0];
284284
$mtime = $tmp[1];
@@ -306,7 +306,7 @@ public function getMetadatas($id)
306306
*/
307307
public function touch($id, $extraLifetime)
308308
{
309-
$tmp = apc_fetch($id);
309+
$tmp = apcu_fetch($id);
310310
if (is_array($tmp)) {
311311
$data = $tmp[0];
312312
$mtime = $tmp[1];
@@ -320,7 +320,7 @@ public function touch($id, $extraLifetime)
320320
if ($newLifetime <=0) {
321321
return false;
322322
}
323-
apc_store($id, array($data, time(), $newLifetime), $newLifetime);
323+
apcu_store($id, array($data, time(), $newLifetime), $newLifetime);
324324
return true;
325325
}
326326
return false;

0 commit comments

Comments
 (0)