diff options
author | Andreas Fischer <bantu@owncloud.com> | 2013-07-25 03:48:26 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2013-07-25 03:48:26 +0200 |
commit | 75e93d041deb301d3a69f35bc43a94b158fa5440 (patch) | |
tree | f14c39108669500b02c9a8ca5c43d267799e9252 | |
parent | ff86b6f1346be9eb90ad82ae49742d22d4ee3e9d (diff) | |
parent | 25003fb21380b71f7c098b8e27263031103e1655 (diff) | |
download | nextcloud-server-75e93d041deb301d3a69f35bc43a94b158fa5440.tar.gz nextcloud-server-75e93d041deb301d3a69f35bc43a94b158fa5440.zip |
Merge pull request #3887 from owncloud/apc_user_cache
The APC User Cache doesn't return the cache_list anymore
* owncloud/apc_user_cache:
Add ACPu memory cache
-rw-r--r-- | lib/memcache/apcu.php | 28 | ||||
-rw-r--r-- | lib/memcache/factory.php | 4 | ||||
-rw-r--r-- | tests/lib/memcache/apc.php | 4 | ||||
-rw-r--r-- | tests/lib/memcache/apcu.php | 20 |
4 files changed, 55 insertions, 1 deletions
diff --git a/lib/memcache/apcu.php b/lib/memcache/apcu.php new file mode 100644 index 00000000000..ccc1aa6e562 --- /dev/null +++ b/lib/memcache/apcu.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Memcache; + +class APCu extends APC { + public function clear($prefix = '') { + $ns = $this->getNamespace() . $prefix; + $ns = preg_quote($ns, '/'); + $iter = new \APCIterator('/^'.$ns.'/'); + return apc_delete($iter); + } + + static public function isAvailable() { + if (!extension_loaded('apcu')) { + return false; + } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) { + return false; + } else { + return true; + } + } +} diff --git a/lib/memcache/factory.php b/lib/memcache/factory.php index b1b49971031..4c1b1ab207f 100644 --- a/lib/memcache/factory.php +++ b/lib/memcache/factory.php @@ -18,6 +18,8 @@ class Factory { function create($prefix = '') { if (XCache::isAvailable()) { return new XCache($prefix); + } elseif (APCu::isAvailable()) { + return new APCu($prefix); } elseif (APC::isAvailable()) { return new APC($prefix); } elseif (Memcached::isAvailable()) { @@ -33,6 +35,6 @@ class Factory { * @return bool */ public function isAvailable() { - return XCache::isAvailable() || APC::isAvailable() || Memcached::isAvailable(); + return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable(); } } diff --git a/tests/lib/memcache/apc.php b/tests/lib/memcache/apc.php index 6b2a49470ba..e5d753a4fa5 100644 --- a/tests/lib/memcache/apc.php +++ b/tests/lib/memcache/apc.php @@ -15,6 +15,10 @@ class APC extends Cache { $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(uniqid()); } } diff --git a/tests/lib/memcache/apcu.php b/tests/lib/memcache/apcu.php new file mode 100644 index 00000000000..7b99e7cd5e0 --- /dev/null +++ b/tests/lib/memcache/apcu.php @@ -0,0 +1,20 @@ +<?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 APCu extends Cache { + public function setUp() { + if(!\OC\Memcache\APCu::isAvailable()) { + $this->markTestSkipped('The APCu extension is not available.'); + return; + } + $this->instance=new \OC\Memcache\APCu(uniqid()); + } +} |