Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lru_cache with cache #3413

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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