Chromium Code Reviews| Index: appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py |
| diff --git a/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py b/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0999a8164203b4114c66d5e4a760e7d01f00e5d9 |
| --- /dev/null |
| +++ b/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py |
| @@ -0,0 +1,27 @@ |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
|
wrengr
2016/12/06 21:52:56
year should be 2016
Sharu Jiang
2016/12/06 23:58:17
Done.
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import functools |
|
wrengr
2016/12/06 21:52:56
I don't think this import is used
Sharu Jiang
2016/12/06 23:58:16
Done.
|
| + |
| +from gae_libs.caches import CompressedMemCache |
| +from gae_libs.caches import PickledMemCache |
| + |
| +from lib.cache_decorator import Cached |
| +from lib.gitiles.gitiles_repository import GitilesRepository |
| + |
| +CACHE_EXPIRE_TIME_SECONDS = 24 * 60 * 60 |
| + |
| + |
| +class CachedGitilesRepository(GitilesRepository): |
| + |
| + @Cached(namespace='Gitiles-json-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, |
| + cache=CompressedMemCache()) |
| + def _SendRequestForJsonResponse(self, url, params=None): # pragma: no cover |
| + return super(CachedGitilesRepository, self)._SendRequestForJsonResponse( |
| + url, params=params) |
| + |
| + @Cached(namespace='Gitiles-text-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, |
| + cache=PickledMemCache()) |
| + def _SendRequestForTextResponse(self, url): # pragma: no cover |
| + return super(CachedGitilesRepository, self)._SendRequestForTextResponse(url) |