Skip to content
Snippets Groups Projects
Verified Commit 6fd897f7 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: More caching

parent aed9cfec
Branches
Tags
1 merge request!160STY: styling
Pipeline #47046 passed
......@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- If a registered identifiable states, that a reference by a Record with parent
RT1 is needed, then now also references from Records that have a child of RT1
as parent are accepted.
- More aggressive caching.
### Deprecated ###
......
......@@ -27,12 +27,13 @@ from __future__ import annotations
import logging
from abc import ABCMeta, abstractmethod
from functools import lru_cache
from datetime import datetime
from typing import Any
import caosdb as db
import yaml
from caosdb.cached import cached_get_entity_by
from caosdb.cached import cached_get_entity_by, cached_query
from .identifiable import Identifiable
from .utils import has_parent
......@@ -43,7 +44,7 @@ logger = logging.getLogger(__name__)
def get_children_of_rt(rtname):
"""Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list"""
return [p.name for p in db.execute_query(f"FIND RECORDTYPE {rtname}")]
return [p.name for p in cached_query(f"FIND RECORDTYPE {rtname}")]
def convert_value(value: Any):
......@@ -510,7 +511,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
def retrieve_identified_record_for_identifiable(self, identifiable: Identifiable):
query_string = self.create_query_for_identifiable(identifiable)
candidates = db.execute_query(query_string)
candidates = cached_query(query_string)
if len(candidates) > 1:
raise RuntimeError(
f"Identifiable was not defined unambigiously.\n{query_string}\nReturned the "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment