From 26095734bffcb3b2cb926dfbbc17ba138a27163c Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 18 Aug 2018 08:35:30 +0200 Subject: [PATCH] better setcache implementation --- tiramisu/setting.py | 11 +++++------ tiramisu/storage/util.py | 12 +++++------- tiramisu/value.py | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 093c329..0b5fdb0 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -349,7 +349,7 @@ class Settings(object): None, None, {}, - None, + {}, 'context_props') if not is_cached: meta = self._getcontext().cfgimpl_get_meta() @@ -361,8 +361,8 @@ class Settings(object): self._p_.setcache(None, None, props, - props, - None) + {}, + props) return props def getproperties(self, @@ -384,7 +384,7 @@ class Settings(object): expires_time, index, props, - None, + {}, 'self_props') else: is_cached = False @@ -405,8 +405,7 @@ class Settings(object): self._p_.setcache(path, index, props, - config_bag.properties, - #FIXME + props, config_bag.properties) return props diff --git a/tiramisu/storage/util.py b/tiramisu/storage/util.py index 0590172..9566bca 100644 --- a/tiramisu/storage/util.py +++ b/tiramisu/storage/util.py @@ -33,13 +33,11 @@ class Cache(DictCache): self._storage = storage super().__init__() - def setcache(self, path, index, val, props, self_props): + def setcache(self, path, index, val, self_props, props): """add val in cache for a specified path if slave, add index """ - #FIXME self_props n'est pas None ! - if 'cache' in props or \ - (self_props is not None and 'cache' in self_props): + if 'cache' in props or 'cache' in self_props: if DEBUG: print('setcache {} with index {} and value {} in {} ({})'.format(path, index, val, _display_classname(self), @@ -75,10 +73,10 @@ class Cache(DictCache): # so value is self_props self_props = value # recheck "cache" value - if 'cache' in props or (self_props is not None and 'cache' in props): + if 'cache' in props or 'cache' in props: if expires_time and timestamp and \ - (props is not None and 'expire' in props or \ - self_props is not None and 'expire' in self_props): + ('expire' in props or \ + 'expire' in self_props): ntime = int(time()) if timestamp + expires_time >= ntime: if DEBUG: diff --git a/tiramisu/value.py b/tiramisu/value.py index 6bb3780..053c0e0 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -98,8 +98,8 @@ class Values(object): self._p_.setcache(option_bag.path, option_bag.index, value, - setting_properties, - option_bag.properties) + option_bag.properties, + setting_properties) if isinstance(value, list): # return a copy, so value cannot be modified return value.copy()