better setcache implementation
This commit is contained in:
parent
89ccfa8aa1
commit
26095734bf
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue