Show More
@@ -41,6 +41,7 b' from rhodecode.lib import rc_cache' | |||
|
41 | 41 | from rhodecode.lib.rc_cache.utils import compute_key_from_params |
|
42 | 42 | from rhodecode.lib.system_info import get_cert_path |
|
43 | 43 | from rhodecode.lib.vcs import exceptions, CurlSession |
|
44 | from rhodecode.lib.utils2 import str2bool | |
|
44 | 45 | |
|
45 | 46 | log = logging.getLogger(__name__) |
|
46 | 47 | |
@@ -242,20 +243,16 b' class RemoteRepo(object):' | |||
|
242 | 243 | context_uid = wire.get('context') |
|
243 | 244 | return context_uid, payload |
|
244 | 245 | |
|
245 | @exceptions.map_vcs_exceptions | |
|
246 | def _call(self, name, *args, **kwargs): | |
|
247 | context_uid, payload = self._base_call(name, *args, **kwargs) | |
|
248 | url = self.url | |
|
249 | ||
|
250 | start = time.time() | |
|
251 | ||
|
246 | def get_local_cache(self, name, args): | |
|
252 | 247 | cache_on = False |
|
253 | 248 | cache_key = '' |
|
254 | local_cache_on = rhodecode.CONFIG.get('vcs.methods.cache') | |
|
249 | local_cache_on = str2bool(rhodecode.CONFIG.get('vcs.methods.cache')) | |
|
255 | 250 | |
|
256 | 251 | cache_methods = [ |
|
257 | 252 | 'branches', 'tags', 'bookmarks', |
|
258 |
'is_large_file', 'is_binary', |
|
|
253 | 'is_large_file', 'is_binary', | |
|
254 | 'fctx_size', 'stream:fctx_node_data', 'blob_raw_length', | |
|
255 | 'node_history', | |
|
259 | 256 | 'revision', 'tree_items', |
|
260 | 257 | 'ctx_list', |
|
261 | 258 | 'bulk_request', |
@@ -267,6 +264,16 b' class RemoteRepo(object):' | |||
|
267 | 264 | call_args = [a for a in args] |
|
268 | 265 | cache_key = compute_key_from_params(repo_state_uid, name, *call_args) |
|
269 | 266 | |
|
267 | return cache_on, cache_key | |
|
268 | ||
|
269 | @exceptions.map_vcs_exceptions | |
|
270 | def _call(self, name, *args, **kwargs): | |
|
271 | context_uid, payload = self._base_call(name, *args, **kwargs) | |
|
272 | url = self.url | |
|
273 | ||
|
274 | start = time.time() | |
|
275 | cache_on, cache_key = self.get_local_cache(name, args) | |
|
276 | ||
|
270 | 277 | @self._cache_region.conditional_cache_on_arguments( |
|
271 | 278 | namespace=self._cache_namespace, condition=cache_on and cache_key) |
|
272 | 279 | def remote_call(_cache_key): |
@@ -288,13 +295,16 b' class RemoteRepo(object):' | |||
|
288 | 295 | url = self.stream_url |
|
289 | 296 | |
|
290 | 297 | start = time.time() |
|
291 | if self._call_with_logging: | |
|
292 | log.debug('Calling %s@%s with args:%.10240r. wire_context: %s', | |
|
293 | url, name, args, context_uid) | |
|
298 | cache_on, cache_key = self.get_local_cache(name, args) | |
|
294 | 299 | |
|
295 | result = _streaming_remote_call(url, payload, EXCEPTIONS_MAP, self._session, | |
|
296 | self.CHUNK_SIZE) | |
|
300 | # Cache is a problem because this is a stream | |
|
301 | def streaming_remote_call(_cache_key): | |
|
302 | if self._call_with_logging: | |
|
303 | log.debug('Calling %s@%s with args:%.10240r. wire_context: %s cache_on: %s', | |
|
304 | url, name, args, context_uid, cache_on) | |
|
305 | return _streaming_remote_call(url, payload, EXCEPTIONS_MAP, self._session, self.CHUNK_SIZE) | |
|
297 | 306 | |
|
307 | result = streaming_remote_call(cache_key) | |
|
298 | 308 | if self._call_with_logging: |
|
299 | 309 | log.debug('Call %s@%s took: %.4fs. wire_context: %s', |
|
300 | 310 | url, name, time.time()-start, context_uid) |
General Comments 0
You need to be logged in to leave comments.
Login now