mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 13:16:44 +02:00
Return 'cache' property in answer_dict
This commit is contained in:
@@ -145,6 +145,7 @@ class Adapter(with_metaclass(AdapterMC, object)):
|
||||
'topic': topic,
|
||||
'topic_type': self._adapter_name,
|
||||
'format': self._get_output_format(topic),
|
||||
'cache': self._cache_needed,
|
||||
}
|
||||
answer_dict.update(answer)
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class UpstreamAdapter(Adapter):
|
||||
+ "?" + options_string
|
||||
try:
|
||||
response = requests.get(url, timeout=CONFIG["upstream.timeout"])
|
||||
answer = response.text
|
||||
answer = {"cache": False, "answer": response.text}
|
||||
except requests.exceptions.ConnectionError:
|
||||
answer = {"cache": False, "answer":_are_you_offline()}
|
||||
return answer
|
||||
|
||||
+2
-1
@@ -182,7 +182,8 @@ class Router(object):
|
||||
}
|
||||
|
||||
answer = self._get_page_dict(topic, topic_type, request_options=request_options)
|
||||
cache.put('q:' + topic, answer)
|
||||
if answer.get("cache", True):
|
||||
cache.put('q:' + topic, answer)
|
||||
return answer
|
||||
|
||||
# Try to find cacheable queries in the cache.
|
||||
|
||||
Reference in New Issue
Block a user