Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: appengine/findit/lib/gitiles/cache_decorator.py

Issue 2344443005: [Findit] Factoring the gitiles (etc) stuff out into its own directory (Closed)
Patch Set: reverted unintended change to an __init__ file Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 # TODO(wrengr): this is the only file in the findit/repository directory
6 # that depends on appengine, and the only thing that depends on this
7 # file is git_repository.py. Ideally we want to break that dependency
8 # by offering a non-cached version of GitRepository as part of the core
9 # library, with the cached version as a subclass in some appengine_utils
stgao 2016/10/28 18:21:00 This is a good idea.
wrengr 2016/10/28 19:24:48 Filed a bug: http://crbug.com/660466
10 # directory. (This is an example of why all the Findit-as-a-library's
11 # clients shoudln't be put in a directory called "handlers", since this
12 # file isn't a handler.
stgao 2016/10/28 18:21:00 Hm, I don't quite understand this though. Mind ela
wrengr 2016/10/28 19:24:48 This was addressing some previous discussions abou
13
5 """This module provides a decorator to cache the results of a function. 14 """This module provides a decorator to cache the results of a function.
6 15
7 Examples: 16 Examples:
8 1. Decorate a function: 17 1. Decorate a function:
9 @cache_decorator.Cached() 18 @cache_decorator.Cached()
10 def Test(a): 19 def Test(a):
11 return a + a 20 return a + a
12 21
13 Test('a') 22 Test('a')
14 Test('a') # Returns the cached 'aa'. 23 Test('a') # Returns the cached 'aa'.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 except Exception: # pragma: no cover. 228 except Exception: # pragma: no cover.
220 logging.exception( 229 logging.exception(
221 'Failed to cache data for function %s.%s, args=%s, kwargs=%s', 230 'Failed to cache data for function %s.%s, args=%s, kwargs=%s',
222 func.__module__, func.__name__, repr(args), repr(kwargs)) 231 func.__module__, func.__name__, repr(args), repr(kwargs))
223 232
224 return result 233 return result
225 234
226 return Wrapped 235 return Wrapped
227 236
228 return Decorator 237 return Decorator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698