Skip to content

Commit

Permalink
Replace lru_cache with cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dekkers committed Aug 28, 2024
1 parent f21217d commit 017aaa8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bytes/bytes/config.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions bytes/bytes/database/db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from functools import lru_cache
from functools import cache

import structlog
from sqlalchemy import create_engine
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions bytes/bytes/rabbitmq.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from functools import lru_cache
from functools import cache

import pika
import pika.exceptions
Expand Down Expand Up @@ -61,7 +61,7 @@ def publish(self, event: Event) -> None:
pass


@lru_cache(maxsize=1)
@cache
def create_event_manager() -> EventManager:
settings = get_settings()

Expand Down
4 changes: 2 additions & 2 deletions octopoes/bits/definitions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {}

Expand Down

0 comments on commit 017aaa8

Please sign in to comment.