Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from contextlib import contextmanager

import redis

from data_retrieval_app.external_data_retrieval.config import settings


@contextmanager
def get_cache():
cache = redis.from_url(str(settings.CACHE_URI), decode_responses=True)

try:
yield cache
finally:
cache.close()
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from pydantic import (
AnyUrl,
HttpUrl,
computed_field,
)
from pydantic_core import MultiHostUrl
from pydantic_settings import BaseSettings, SettingsConfigDict


Expand All @@ -20,6 +22,22 @@ def BACKEND_BASE_URL(self) -> HttpUrl:
else:
return HttpUrl("http://src-backend-1:8000/api/api_v1")

REDIS_PORT: int = 6379
REDIS_SERVER: str
REDIS_CACHE: str = str(0)
REDIS_PASSWORD: str = ""

@computed_field # type: ignore[prop-decorator]
@property
def CACHE_URI(self) -> AnyUrl:
return MultiHostUrl.build(
scheme="redis",
password=self.REDIS_PASSWORD,
host=self.REDIS_SERVER,
port=self.REDIS_PORT,
path=self.REDIS_CACHE,
)

MANUAL_NEXT_CHANGE_ID: bool
NEXT_CHANGE_ID: str
OATH_ACC_TOKEN_CONTACT_EMAIL: str
Expand Down
Loading
Loading