diff --git a/lib/private/Memcache/APC.php b/lib/private/Memcache/APC.php deleted file mode 100644 index d2454cd1c13c..000000000000 --- a/lib/private/Memcache/APC.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @author Clark Tomlinson - * @author Morris Jobke - * @author Otto Sabart - * @author Robin Appelman - * - * @copyright Copyright (c) 2018, ownCloud GmbH - * @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 - * - */ - -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; - } -} diff --git a/lib/private/Memcache/XCache.php b/lib/private/Memcache/XCache.php deleted file mode 100644 index 5f318eed510b..000000000000 --- a/lib/private/Memcache/XCache.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @author Bart Visscher - * @author Clark Tomlinson - * @author Joas Schilling - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2018, ownCloud GmbH - * @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 - * - */ - -namespace OC\Memcache; - -use OCP\IMemcache; - -/** - * See http://xcache.lighttpd.net/wiki/XcacheApi for provided constants and - * functions etc. - */ -class XCache extends Cache implements IMemcache { - use CASTrait; - - use CADTrait; - - /** - * entries in XCache gets namespaced to prevent collisions between ownCloud instances and users - */ - protected function getNameSpace() { - return $this->prefix; - } - - public function get($key) { - return xcache_get($this->getNamespace() . $key); - } - - public function set($key, $value, $ttl = 0) { - if ($ttl > 0) { - return xcache_set($this->getNamespace() . $key, $value, $ttl); - } else { - return xcache_set($this->getNamespace() . $key, $value); - } - } - - public function hasKey($key) { - return xcache_isset($this->getNamespace() . $key); - } - - public function remove($key) { - return xcache_unset($this->getNamespace() . $key); - } - - public function clear($prefix = '') { - if (function_exists('xcache_unset_by_prefix')) { - return xcache_unset_by_prefix($this->getNamespace() . $prefix); - } else { - // Since we can not clear by prefix, we just clear the whole cache. - xcache_clear_cache(\XC_TYPE_VAR, 0); - } - return true; - } - - /** - * 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) { - if ($this->hasKey($key)) { - return false; - } else { - return $this->set($key, $value, $ttl); - } - } - - /** - * Increase a stored number - * - * @param string $key - * @param int $step - * @return int | bool - */ - public function inc($key, $step = 1) { - return xcache_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 xcache_dec($this->getPrefix() . $key, $step); - } - - static public function isAvailable() { - if (!extension_loaded('xcache')) { - return false; - } - if (\OC::$CLI && !getenv('XCACHE_TEST')) { - return false; - } - if (!function_exists('xcache_unset_by_prefix') && \OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) { - // We do not want to use XCache if we can not clear it without - // using the administration function xcache_clear_cache() - // AND administration functions are password-protected. - return false; - } - $var_size = \OC::$server->getIniWrapper()->getBytes('xcache.var_size'); - if (!$var_size) { - return false; - } - return true; - } -} diff --git a/tests/lib/Memcache/APCTest.php b/tests/lib/Memcache/APCTest.php deleted file mode 100644 index 4bd7e62b94a2..000000000000 --- a/tests/lib/Memcache/APCTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * 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()); - } -} diff --git a/tests/lib/Memcache/XCacheTest.php b/tests/lib/Memcache/XCacheTest.php deleted file mode 100644 index af720115d014..000000000000 --- a/tests/lib/Memcache/XCacheTest.php +++ /dev/null @@ -1,22 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Memcache; - -class XCacheTest extends Cache { - protected function setUp() { - parent::setUp(); - - if (!\OC\Memcache\XCache::isAvailable()) { - $this->markTestSkipped('The xcache extension is not available.'); - return; - } - $this->instance = new \OC\Memcache\XCache($this->getUniqueID()); - } -}