-
Notifications
You must be signed in to change notification settings - Fork 31
Cache CUAHSI GetServicesInBox2 results #1932
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
Labels
Comments
Commenting to subscribe to this thread and get email notifications. |
This can be done fairly easily along these lines: diff --git a/src/mmw/apps/bigcz/clients/cuahsi/search.py b/src/mmw/apps/bigcz/clients/cuahsi/search.py
index 08622b4..955f8cd 100644
--- a/src/mmw/apps/bigcz/clients/cuahsi/search.py
+++ b/src/mmw/apps/bigcz/clients/cuahsi/search.py
@@ -124,8 +124,16 @@ def group_series_by_location(series):
def make_request(request, **kwargs):
+ key = 'bigcz_{}_{}'.format(request.__name__,
+ hash(frozenset(kwargs.items())))
+ cached = cache.get(key)
+ if cached:
+ return cached
+
try:
- return request(**kwargs)
+ response = request(**kwargs)
+ cache.set(key, response)
+ return response
except URLError, e:
if isinstance(e.reason, timeout):
raise RequestTimedOutError() Will need to ensure that this expires at appropriate times, because this is not an immutable operation. |
rajadain
added a commit
that referenced
this issue
Sep 20, 2017
…uests BiG-CZ: Cache CUAHSI Requests Connects #1932
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref: #1931 (comment)
The text was updated successfully, but these errors were encountered: