From 71f9f5ec4a719a9ea5e376c1f0d48ab35f6819a6 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 27 Jan 2024 10:53:29 +0200 Subject: [PATCH] cache Room::_namespace, fix keys, use default timeout --- src/controller/room.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/controller/room.php b/src/controller/room.php index 54597be..2d1f0ad 100644 --- a/src/controller/room.php +++ b/src/controller/room.php @@ -332,6 +332,7 @@ class Room // Check for cache $result = $this->_memory->get( [ + 'Room::_post', $namespace, $key, $field @@ -340,6 +341,7 @@ class Room $time = $this->_memory->get( [ + 'Room::_post', $namespace, $key, $field, @@ -538,23 +540,23 @@ class Room // Check for cached results $this->_memory->set( [ + 'Room::_post', $namespace, $key, $field ], - $result, - time() + 60 + $result ); $this->_memory->set( [ + 'Room::_post', $namespace, $key, $field, $time ], - $time, - time() + 60 + $time ); return $result; @@ -819,11 +821,25 @@ class Room public function _namespace(string $namespace): ?string { + // Check for cache + if ($result = $this->_memory->get(['Room::_namespace', $namespace])) + { + return $result; + } + // Find local name foreach ((array) $this->_kevacoin->kevaListNamespaces() as $record) { if ($record['namespaceId'] == $namespace) { + $this->_memory->set( + [ + 'Room::_namespace', + $namespace + ], + $time + ); + return $record['displayName']; } }