| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import functools | 5 import functools |
| 6 | 6 |
| 7 from gae_libs.caches import CompressedMemCache | 7 from gae_libs.caches import CompressedMemCache |
| 8 from gae_libs.caches import PickledMemCache | 8 from gae_libs.caches import PickledMemCache |
| 9 | 9 |
| 10 from lib.cache_decorator import Cached | 10 from libs.cache_decorator import Cached |
| 11 from lib.gitiles.gitiles_repository import GitilesRepository | 11 from libs.gitiles.gitiles_repository import GitilesRepository |
| 12 | 12 |
| 13 CACHE_EXPIRE_TIME_SECONDS = 24 * 60 * 60 | 13 CACHE_EXPIRE_TIME_SECONDS = 24 * 60 * 60 |
| 14 | 14 |
| 15 | 15 |
| 16 class CachedGitilesRepository(GitilesRepository): | 16 class CachedGitilesRepository(GitilesRepository): |
| 17 | 17 |
| 18 @Cached(namespace='Gitiles-json-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, | 18 @Cached(namespace='Gitiles-json-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, |
| 19 cache=CompressedMemCache()) | 19 cache=CompressedMemCache()) |
| 20 def _SendRequestForJsonResponse(self, url, params=None): # pragma: no cover | 20 def _SendRequestForJsonResponse(self, url, params=None): # pragma: no cover |
| 21 return super(CachedGitilesRepository, self)._SendRequestForJsonResponse( | 21 return super(CachedGitilesRepository, self)._SendRequestForJsonResponse( |
| 22 url, params=params) | 22 url, params=params) |
| 23 | 23 |
| 24 @Cached(namespace='Gitiles-text-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, | 24 @Cached(namespace='Gitiles-text-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, |
| 25 cache=PickledMemCache()) | 25 cache=PickledMemCache()) |
| 26 def _SendRequestForTextResponse(self, url): # pragma: no cover | 26 def _SendRequestForTextResponse(self, url): # pragma: no cover |
| 27 return super(CachedGitilesRepository, self)._SendRequestForTextResponse(url) | 27 return super(CachedGitilesRepository, self)._SendRequestForTextResponse(url) |
| OLD | NEW |