mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Merge pull request #30775 from nextcloud/backport/30769/stable21
This commit is contained in:
commit
6cad3982cd
1 changed files with 2 additions and 21 deletions
|
|
@ -134,27 +134,8 @@ class Memcached extends Cache implements IMemcache {
|
|||
}
|
||||
|
||||
public function clear($prefix = '') {
|
||||
$prefix = $this->getNameSpace() . $prefix;
|
||||
$allKeys = self::$cache->getAllKeys();
|
||||
if ($allKeys === false) {
|
||||
// newer Memcached doesn't like getAllKeys(), flush everything
|
||||
self::$cache->flush();
|
||||
return true;
|
||||
}
|
||||
$keys = [];
|
||||
$prefixLength = strlen($prefix);
|
||||
foreach ($allKeys as $key) {
|
||||
if (substr($key, 0, $prefixLength) === $prefix) {
|
||||
$keys[] = $key;
|
||||
}
|
||||
}
|
||||
if (method_exists(self::$cache, 'deleteMulti')) {
|
||||
self::$cache->deleteMulti($keys);
|
||||
} else {
|
||||
foreach ($keys as $key) {
|
||||
self::$cache->delete($key);
|
||||
}
|
||||
}
|
||||
// Newer Memcached doesn't like getAllKeys(), flush everything
|
||||
self::$cache->flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue