Browse Source

cache room::_clitoris

main
ghost 9 months ago
parent
commit
0538b35957
  1. 18
      src/controller/room.php

18
src/controller/room.php

@ -793,6 +793,12 @@ class Room @@ -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 @@ -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;
}
}
}

Loading…
Cancel
Save