Browse Source

cache Room::_namespace, fix keys, use default timeout

main
ghost 9 months ago
parent
commit
71f9f5ec4a
  1. 24
      src/controller/room.php

24
src/controller/room.php

@ -332,6 +332,7 @@ class Room
// Check for cache // Check for cache
$result = $this->_memory->get( $result = $this->_memory->get(
[ [
'Room::_post',
$namespace, $namespace,
$key, $key,
$field $field
@ -340,6 +341,7 @@ class Room
$time = $this->_memory->get( $time = $this->_memory->get(
[ [
'Room::_post',
$namespace, $namespace,
$key, $key,
$field, $field,
@ -538,23 +540,23 @@ class Room
// Check for cached results // Check for cached results
$this->_memory->set( $this->_memory->set(
[ [
'Room::_post',
$namespace, $namespace,
$key, $key,
$field $field
], ],
$result, $result
time() + 60
); );
$this->_memory->set( $this->_memory->set(
[ [
'Room::_post',
$namespace, $namespace,
$key, $key,
$field, $field,
$time $time
], ],
$time, $time
time() + 60
); );
return $result; return $result;
@ -819,11 +821,25 @@ class Room
public function _namespace(string $namespace): ?string public function _namespace(string $namespace): ?string
{ {
// Check for cache
if ($result = $this->_memory->get(['Room::_namespace', $namespace]))
{
return $result;
}
// Find local name // Find local name
foreach ((array) $this->_kevacoin->kevaListNamespaces() as $record) foreach ((array) $this->_kevacoin->kevaListNamespaces() as $record)
{ {
if ($record['namespaceId'] == $namespace) if ($record['namespaceId'] == $namespace)
{ {
$this->_memory->set(
[
'Room::_namespace',
$namespace
],
$time
);
return $record['displayName']; return $record['displayName'];
} }
} }

Loading…
Cancel
Save