Skip to content
Snippets Groups Projects
Commit cd147bb3 authored by Robin Appelman's avatar Robin Appelman
Browse files

Use APCIterator for Memcache\APC::clear()

parent 1df1b55b
Branches
No related tags found
No related merge requests found
...@@ -9,15 +9,8 @@ ...@@ -9,15 +9,8 @@
namespace OC\Memcache; namespace OC\Memcache;
class APC extends Cache { class APC extends Cache {
/**
* entries in APC gets namespaced to prevent collisions between owncloud instances and users
*/
protected function getNameSpace() {
return $this->prefix;
}
public function get($key) { public function get($key) {
$result = apc_fetch($this->getNamespace() . $key, $success); $result = apc_fetch($this->getPrefix() . $key, $success);
if (!$success) { if (!$success) {
return null; return null;
} }
...@@ -25,26 +18,22 @@ class APC extends Cache { ...@@ -25,26 +18,22 @@ class APC extends Cache {
} }
public function set($key, $value, $ttl = 0) { public function set($key, $value, $ttl = 0) {
return apc_store($this->getNamespace() . $key, $value, $ttl); return apc_store($this->getPrefix() . $key, $value, $ttl);
} }
public function hasKey($key) { public function hasKey($key) {
return apc_exists($this->getNamespace() . $key); return apc_exists($this->getPrefix() . $key);
} }
public function remove($key) { public function remove($key) {
return apc_delete($this->getNamespace() . $key); return apc_delete($this->getPrefix() . $key);
} }
public function clear($prefix = '') { public function clear($prefix = '') {
$ns = $this->getNamespace() . $prefix; $ns = $this->getPrefix() . $prefix;
$cache = apc_cache_info('user'); $ns = preg_quote($ns, '/');
foreach ($cache['cache_list'] as $entry) { $iter = new \APCIterator('user', '/^' . $ns . '/');
if (strpos($entry['info'], $ns) === 0) { return apc_delete($iter);
apc_delete($entry['info']);
}
}
return true;
} }
static public function isAvailable() { static public function isAvailable() {
......
...@@ -9,13 +9,6 @@ ...@@ -9,13 +9,6 @@
namespace OC\Memcache; namespace OC\Memcache;
class APCu extends APC { class APCu extends APC {
public function clear($prefix = '') {
$ns = $this->getNamespace() . $prefix;
$ns = preg_quote($ns, '/');
$iter = new \APCIterator('user', '/^'.$ns.'/');
return apc_delete($iter);
}
static public function isAvailable() { static public function isAvailable() {
if (!extension_loaded('apcu')) { if (!extension_loaded('apcu')) {
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment