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

NEW: Django backends use the default cache by default 🧑‍💻 #52

Merged
merged 1 commit into from
Aug 4, 2023
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 cachetory/backends/async_/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import AsyncIterable, Generic, Iterable
from urllib.parse import urlparse

from django.core.cache import BaseCache, caches # type: ignore[import]
from django.core.cache import BaseCache, cache, caches # type: ignore[import]
from django.core.cache.backends.base import DEFAULT_TIMEOUT # type: ignore[import]

from cachetory.interfaces.backends.async_ import AsyncBackend
Expand All @@ -23,7 +23,7 @@ class DjangoBackend(AsyncBackend[WireT], Generic[WireT]):
def from_url(cls, url: str) -> DjangoBackend[WireT]:
return DjangoBackend(caches[urlparse(url).hostname])

def __init__(self, cache: BaseCache) -> None:
def __init__(self, cache: BaseCache = cache) -> None:
"""Initialize backend with the Django cache instance."""
self._cache = cache

Expand Down
4 changes: 2 additions & 2 deletions cachetory/backends/sync/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Generic, Iterable
from urllib.parse import urlparse

from django.core.cache import BaseCache, caches # type: ignore[import]
from django.core.cache import BaseCache, cache, caches # type: ignore[import]
from django.core.cache.backends.base import DEFAULT_TIMEOUT # type: ignore[import]

from cachetory.interfaces.backends.private import WireT
Expand All @@ -23,7 +23,7 @@ class DjangoBackend(SyncBackend[WireT], Generic[WireT]):
def from_url(cls, url: str) -> DjangoBackend[WireT]:
return DjangoBackend(caches[urlparse(url).hostname])

def __init__(self, cache: BaseCache) -> None:
def __init__(self, cache: BaseCache = cache) -> None:
"""Initialize backend with the Django cache instance."""
self._cache = cache

Expand Down