From 0538b35957e4c4d34756071122c6dc9f269f35f8 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 27 Jan 2024 11:08:11 +0200 Subject: [PATCH] cache room::_clitoris --- src/controller/room.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/controller/room.php b/src/controller/room.php index 6fcc4f9..711cc13 100644 --- a/src/controller/room.php +++ b/src/controller/room.php @@ -793,6 +793,12 @@ class Room private function _clitoris(string $namespace): ?string { + // Check for cache + if ($result = $this->_memory->get([__METHOD__, $namespace])) + { + return $result; + } + // Validate namespace supported to continue if (preg_match('/^N[A-z0-9]{33}$/', $namespace)) { @@ -805,13 +811,23 @@ class Room if ($reader->valid()) { - return sprintf( + $result = sprintf( '%s (%s)', $reader->fileName() ? $reader->fileName() : $namespace, $this->_bytes( (int) $reader->fileSize() ) ); + + $this->_memory->set( + [ + __METHOD__, + $namespace + ], + $result + ); + + return $result; } } }