diff options
Diffstat (limited to 'lib/private/Memcache/APCu.php')
-rw-r--r-- | lib/private/Memcache/APCu.php | 69 |
1 files changed, 13 insertions, 56 deletions
diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php index f0eb98b9db2..937f8a863ab 100644 --- a/lib/private/Memcache/APCu.php +++ b/lib/private/Memcache/APCu.php @@ -1,29 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Andreas Fischer <bantu@owncloud.com> - * @author Bart Visscher <bartv@thisnet.nl> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * @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/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OC\Memcache; @@ -46,6 +26,9 @@ class APCu extends Cache implements IMemcache { } public function set($key, $value, $ttl = 0) { + if ($ttl === 0) { + $ttl = self::DEFAULT_TTL; + } return apcu_store($this->getPrefix() . $key, $value, $ttl); } @@ -77,6 +60,9 @@ class APCu extends Cache implements IMemcache { * @return bool */ public function add($key, $value, $ttl = 0) { + if ($ttl === 0) { + $ttl = self::DEFAULT_TTL; + } return apcu_add($this->getPrefix() . $key, $value, $ttl); } @@ -88,22 +74,8 @@ class APCu extends Cache implements IMemcache { * @return int | bool */ public function inc($key, $step = 1) { - $this->add($key, 0); - /** - * TODO - hack around a PHP 7 specific issue in APCu - * - * on PHP 7 the apcu_inc method on a non-existing object will increment - * "0" and result in "1" as value - therefore we check for existence - * first - * - * on PHP 5.6 this is not the case - * - * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221 - * for details - */ - return apcu_exists($this->getPrefix() . $key) - ? apcu_inc($this->getPrefix() . $key, $step) - : false; + $success = null; + return apcu_inc($this->getPrefix() . $key, $step, $success, self::DEFAULT_TTL); } /** @@ -114,18 +86,6 @@ class APCu extends Cache implements IMemcache { * @return int | bool */ public function dec($key, $step = 1) { - /** - * TODO - hack around a PHP 7 specific issue in APCu - * - * on PHP 7 the apcu_dec method on a non-existing object will decrement - * "0" and result in "-1" as value - therefore we check for existence - * first - * - * on PHP 5.6 this is not the case - * - * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221 - * for details - */ return apcu_exists($this->getPrefix() . $key) ? apcu_dec($this->getPrefix() . $key, $step) : false; @@ -155,10 +115,7 @@ class APCu extends Cache implements IMemcache { return false; } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enable_cli') && \OC::$CLI) { return false; - } elseif ( - version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 && - version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1 - ) { + } elseif (version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1) { return false; } else { return true; |