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
Merged

Custom cache page #2311

merged 12 commits into from
Nov 20, 2024

Conversation

moisses89
Copy link
Member

Closes #2008

@moisses89 moisses89 force-pushed the custom_cache_page branch 2 times, most recently from d96c7f9 to 6199cbc Compare November 8, 2024 11:02
@moisses89 moisses89 marked this pull request as ready for review November 11, 2024 16:22
@moisses89 moisses89 requested a review from a team as a code owner November 11, 2024 16:22
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
safe_transaction_service/history/cache.py Show resolved Hide resolved
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
query_params = request.request.GET.dict()
cache_path = f"{urlencode(query_params)}"
# Calculate cache_name
address = request.kwargs["address"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "address" should be an optional parameter to the decorator, so we can use different keys in the future

Also this can throw an exception if address does not exist. It should be: request.kwargs.get("address") so you can emit a warning when you evaluate if address: later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea here is to start by the cases where a Safe is a part of the URL path.
Later if we are happy with the results we can move forward to other endpoints. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, making address as a url path value configurable is just adding an optional parameter (by default 'address') to the decorator, something like caching_value_name

safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
config/settings/base.py Outdated Show resolved Hide resolved
@moisses89 moisses89 requested a review from Uxio0 November 18, 2024 15:09
safe_transaction_service/history/cache.py Outdated Show resolved Hide resolved
@moisses89 moisses89 merged commit 7079e5b into main Nov 20, 2024
5 checks passed
@moisses89 moisses89 deleted the custom_cache_page branch November 20, 2024 10:10
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a common cache class for all the transaction service endpoints
2 participants