diff --git a/bytes/bytes/config.py b/bytes/bytes/config.py index 056f6fa3f39..4f9b61f1c97 100644 --- a/bytes/bytes/config.py +++ b/bytes/bytes/config.py @@ -1,6 +1,6 @@ import logging import os -from functools import lru_cache +from functools import cache from pathlib import Path from typing import Any, Literal @@ -155,7 +155,7 @@ def settings_customise_sources( return env_settings, init_settings, file_secret_settings, backwards_compatible_settings -@lru_cache +@cache def get_settings() -> Settings: return Settings() diff --git a/bytes/bytes/database/db.py b/bytes/bytes/database/db.py index 3df22afe107..922ea4ee499 100644 --- a/bytes/bytes/database/db.py +++ b/bytes/bytes/database/db.py @@ -1,4 +1,4 @@ -from functools import lru_cache +from functools import cache import structlog from sqlalchemy import create_engine @@ -10,7 +10,7 @@ SQL_BASE = declarative_base() -@lru_cache(maxsize=1) +@cache def get_engine(db_uri: str, pool_size: int) -> Engine: """Returns database engine according to config settings.""" db_uri_redacted = make_url(name_or_url=str(db_uri)).render_as_string(hide_password=True) diff --git a/bytes/bytes/rabbitmq.py b/bytes/bytes/rabbitmq.py index 75aebc4ab54..4ffa498ddd8 100644 --- a/bytes/bytes/rabbitmq.py +++ b/bytes/bytes/rabbitmq.py @@ -1,4 +1,4 @@ -from functools import lru_cache +from functools import cache import pika import pika.exceptions @@ -61,7 +61,7 @@ def publish(self, event: Event) -> None: pass -@lru_cache(maxsize=1) +@cache def create_event_manager() -> EventManager: settings = get_settings() diff --git a/octopoes/bits/definitions.py b/octopoes/bits/definitions.py index 58e82a19dcb..8c6dac010b9 100644 --- a/octopoes/bits/definitions.py +++ b/octopoes/bits/definitions.py @@ -1,6 +1,6 @@ import importlib import pkgutil -from functools import lru_cache +from functools import cache from logging import getLogger from pathlib import Path from types import ModuleType @@ -29,7 +29,7 @@ class BitDefinition(BaseModel): config_ooi_relation_path: str | None = None -@lru_cache(maxsize=32) +@cache def get_bit_definitions() -> dict[str, BitDefinition]: bit_definitions = {}