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

Custom cache page #2311

Merged
merged 12 commits into from
Nov 20, 2024
6 changes: 4 additions & 2 deletions safe_transaction_service/history/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def remove_cache(self):


def cache_txs_view_for_address(
cache_tag: str, timeout: int = settings.CACHE_VIEW_DEFAULT_TIMEOUT
cache_tag: str,
parameter_key: Optional["str"] = "address",
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
timeout: int = settings.CACHE_VIEW_DEFAULT_TIMEOUT,
):
"""
Custom cache decorator that caches the view response.
Expand All @@ -115,7 +117,7 @@ def _wrapped_view(request, *args, **kwargs):
query_params = sorted(request.request.GET.dict().items())
cache_path = urlencode(query_params)
# Calculate cache_name
address = request.kwargs.get("address")
address = request.kwargs.get(parameter_key)
cache_txs_view: Optional[CacheSafeTxsView] = None
if address:
cache_txs_view = CacheSafeTxsView(cache_tag, address)
Expand Down