From 8f1199453702c0d301c46225d2a1fc4689b62d21 Mon Sep 17 00:00:00 2001
From: Côme Chilliet <come.chilliet@nextcloud.com>
Date: Thu, 20 Jan 2022 11:20:18 +0100
Subject: Always call flush() as getAllKeys() is broken
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
---
 lib/private/Memcache/Memcached.php | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php
index 7b852a418e1..9dab74e0e59 100644
--- a/lib/private/Memcache/Memcached.php
+++ b/lib/private/Memcache/Memcached.php
@@ -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;
 	}
 
-- 
cgit v1.2.3