database: improve ns_contains method
It isn't necessary to read out the entire namespace, just attempt to fetch the record and reduce the key list. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
43c1b998b0
commit
e754d123dd
@ -406,10 +406,11 @@ class MoonrakerDatabase:
|
|||||||
with self.thread_lock:
|
with self.thread_lock:
|
||||||
try:
|
try:
|
||||||
key_list = self._process_key(key)
|
key_list = self._process_key(key)
|
||||||
|
record = self._get_record(namespace, key_list[0])
|
||||||
if len(key_list) == 1:
|
if len(key_list) == 1:
|
||||||
return key_list[0] in self.ns_keys(namespace)
|
return True
|
||||||
ns = self._get_namespace(namespace)
|
reduce(operator.getitem, # type: ignore
|
||||||
reduce(operator.getitem, key_list[1:], ns)
|
key_list[1:], record)
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user