Merge pull request #2946 from nextcloud/kill-apc
Kill APC because it requires PHP 5.4 or lower
This commit is contained in:
commit
64097aece9
|
@ -909,7 +909,6 @@ $CONFIG = array(
|
|||
*
|
||||
* Available cache backends:
|
||||
*
|
||||
* * ``\OC\Memcache\APC`` Alternative PHP Cache backend
|
||||
* * ``\OC\Memcache\APCu`` APC user backend
|
||||
* * ``\OC\Memcache\ArrayCache`` In-memory array-based backend (not recommended)
|
||||
* * ``\OC\Memcache\Memcached`` Memcached backend
|
||||
|
|
|
@ -605,7 +605,6 @@ return array(
|
|||
'OC\\Log\\Syslog' => $baseDir . '/lib/private/Log/Syslog.php',
|
||||
'OC\\Mail\\Mailer' => $baseDir . '/lib/private/Mail/Mailer.php',
|
||||
'OC\\Mail\\Message' => $baseDir . '/lib/private/Mail/Message.php',
|
||||
'OC\\Memcache\\APC' => $baseDir . '/lib/private/Memcache/APC.php',
|
||||
'OC\\Memcache\\APCu' => $baseDir . '/lib/private/Memcache/APCu.php',
|
||||
'OC\\Memcache\\ArrayCache' => $baseDir . '/lib/private/Memcache/ArrayCache.php',
|
||||
'OC\\Memcache\\CADTrait' => $baseDir . '/lib/private/Memcache/CADTrait.php',
|
||||
|
|
|
@ -635,7 +635,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Log\\Syslog' => __DIR__ . '/../../..' . '/lib/private/Log/Syslog.php',
|
||||
'OC\\Mail\\Mailer' => __DIR__ . '/../../..' . '/lib/private/Mail/Mailer.php',
|
||||
'OC\\Mail\\Message' => __DIR__ . '/../../..' . '/lib/private/Mail/Message.php',
|
||||
'OC\\Memcache\\APC' => __DIR__ . '/../../..' . '/lib/private/Memcache/APC.php',
|
||||
'OC\\Memcache\\APCu' => __DIR__ . '/../../..' . '/lib/private/Memcache/APCu.php',
|
||||
'OC\\Memcache\\ArrayCache' => __DIR__ . '/../../..' . '/lib/private/Memcache/ArrayCache.php',
|
||||
'OC\\Memcache\\CADTrait' => __DIR__ . '/../../..' . '/lib/private/Memcache/CADTrait.php',
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Andreas Fischer <bantu@owncloud.com>
|
||||
* @author Clark Tomlinson <fallen013@gmail.com>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Otto Sabart <ottosabart@seberm.com>
|
||||
* @author Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Memcache;
|
||||
|
||||
use OCP\IMemcache;
|
||||
|
||||
class APC extends Cache implements IMemcache {
|
||||
use CASTrait {
|
||||
cas as casEmulated;
|
||||
}
|
||||
|
||||
use CADTrait;
|
||||
|
||||
public function get($key) {
|
||||
$result = apc_fetch($this->getPrefix() . $key, $success);
|
||||
if (!$success) {
|
||||
return null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function set($key, $value, $ttl = 0) {
|
||||
return apc_store($this->getPrefix() . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
public function hasKey($key) {
|
||||
return apc_exists($this->getPrefix() . $key);
|
||||
}
|
||||
|
||||
public function remove($key) {
|
||||
return apc_delete($this->getPrefix() . $key);
|
||||
}
|
||||
|
||||
public function clear($prefix = '') {
|
||||
$ns = $this->getPrefix() . $prefix;
|
||||
$ns = preg_quote($ns, '/');
|
||||
$iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
|
||||
return apc_delete($iter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in the cache if it's not already stored
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl Time To Live in seconds. Defaults to 60*60*24
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $ttl = 0) {
|
||||
return apc_add($this->getPrefix() . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase a stored number
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $step
|
||||
* @return int | bool
|
||||
*/
|
||||
public function inc($key, $step = 1) {
|
||||
$this->add($key, 0);
|
||||
return apc_inc($this->getPrefix() . $key, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease a stored number
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $step
|
||||
* @return int | bool
|
||||
*/
|
||||
public function dec($key, $step = 1) {
|
||||
return apc_dec($this->getPrefix() . $key, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare and set
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $old
|
||||
* @param mixed $new
|
||||
* @return bool
|
||||
*/
|
||||
public function cas($key, $old, $new) {
|
||||
// apc only does cas for ints
|
||||
if (is_int($old) and is_int($new)) {
|
||||
return apc_cas($this->getPrefix() . $key, $old, $new);
|
||||
} else {
|
||||
return $this->casEmulated($key, $old, $new);
|
||||
}
|
||||
}
|
||||
|
||||
static public function isAvailable() {
|
||||
if (!extension_loaded('apc')) {
|
||||
return false;
|
||||
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
|
||||
return false;
|
||||
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('apc_exists')) {
|
||||
function apc_exists($keys) {
|
||||
$result = false;
|
||||
apc_fetch($keys, $result);
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -83,7 +83,7 @@ class Factory implements ICacheFactory {
|
|||
|
||||
$missingCacheMessage = 'Memcache {class} not available for {use} cache';
|
||||
$missingCacheHint = 'Is the matching PHP module installed and enabled?';
|
||||
if (!$localCacheClass::isAvailable()) {
|
||||
if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) {
|
||||
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
|
||||
// CLI should not hard-fail on broken memcache
|
||||
$this->logger->info($missingCacheMessage, [
|
||||
|
@ -98,7 +98,7 @@ class Factory implements ICacheFactory {
|
|||
]), $missingCacheHint);
|
||||
}
|
||||
}
|
||||
if (!$distributedCacheClass::isAvailable()) {
|
||||
if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) {
|
||||
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
|
||||
// CLI should not hard-fail on broken memcache
|
||||
$this->logger->info($missingCacheMessage, [
|
||||
|
@ -113,7 +113,7 @@ class Factory implements ICacheFactory {
|
|||
]), $missingCacheHint);
|
||||
}
|
||||
}
|
||||
if (!($lockingCacheClass && $lockingCacheClass::isAvailable())) {
|
||||
if (!($lockingCacheClass && class_exists($distributedCacheClass) && $lockingCacheClass::isAvailable())) {
|
||||
// don't fallback since the fallback might not be suitable for storing lock
|
||||
$lockingCacheClass = self::NULL_CACHE;
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace Test\Memcache;
|
||||
|
||||
class APCTest extends Cache {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
if(!\OC\Memcache\APC::isAvailable()) {
|
||||
$this->markTestSkipped('The apc extension is not available.');
|
||||
return;
|
||||
}
|
||||
if(\OC\Memcache\APCu::isAvailable()) {
|
||||
$this->markTestSkipped('The apc extension is emulated by ACPu.');
|
||||
return;
|
||||
}
|
||||
$this->instance=new \OC\Memcache\APC($this->getUniqueID());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue