diff options
author | Ruben Pollan <meskio@sindominio.net> | 2014-09-16 10:51:09 -0500 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2014-09-16 13:01:59 -0500 |
commit | c9662e6aff3a3f893b6a0f84d0e68c7f239ab117 (patch) | |
tree | 1aa448385bc61a27777efe64bac55ee7bbf743f6 /src/leap | |
parent | 2498d0c1712b06efe6ac29d883d3a80b541fe765 (diff) |
Add invalidation timeout to cache
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/common/decorators.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/leap/common/decorators.py b/src/leap/common/decorators.py index 2ef6711..99c3653 100644 --- a/src/leap/common/decorators.py +++ b/src/leap/common/decorators.py @@ -144,17 +144,20 @@ class _memoized(object): return functools.partial(self.__call__, obj) -def memoized_method(function=None, ignore_kwargs=None): +def memoized_method(function=None, ignore_kwargs=None, + invalidation=_memoized.CACHE_INVALIDATION_DELTA): """ Wrap _memoized to allow for deferred calling :type function: callable, or None. :type ignore_kwargs: None, True or tuple. + :type invalidation: int seconds. """ if function: - return _memoized(function, is_method=True) + return _memoized(function, is_method=True, invalidation=invalidation) else: def wrapper(function): return _memoized( - function, ignore_kwargs=ignore_kwargs, is_method=True) + function, ignore_kwargs=ignore_kwargs, is_method=True, + invalidation=invalidation) return wrapper |