add 'cache' property
This commit is contained in:
@ -35,7 +35,7 @@ ro_append = set(['frozen', 'disabled', 'validator', 'everything_frozen',
|
||||
'mandatory'])
|
||||
rw_remove = set(['permissive', 'everything_frozen', 'mandatory'])
|
||||
rw_append = set(['frozen', 'disabled', 'validator', 'hidden'])
|
||||
default_properties = ('expire', 'validator')
|
||||
default_properties = ('cache', 'expire', 'validator')
|
||||
|
||||
|
||||
class _NameSpace:
|
||||
@ -242,18 +242,21 @@ class Settings(object):
|
||||
raise ValueError(_('if opt is not None, path should not be'
|
||||
' None in _getproperties'))
|
||||
ntime = None
|
||||
if self._p_.hascache('property', path):
|
||||
ntime = time()
|
||||
is_cached, props = self._p_.getcache('property', path, ntime)
|
||||
if 'cache' in self and self._p_.hascache(path):
|
||||
if 'expire' in self:
|
||||
ntime = int(time())
|
||||
is_cached, props = self._p_.getcache(path, ntime)
|
||||
if is_cached:
|
||||
return props
|
||||
props = self._p_.getproperties(path, opt._properties)
|
||||
if is_apply_req:
|
||||
props |= self.apply_requires(opt, path)
|
||||
if 'expire' in self:
|
||||
if ntime is None:
|
||||
ntime = time()
|
||||
self._p_.setcache('property', path, props, ntime + expires_time)
|
||||
if 'cache' in self:
|
||||
if 'expire' in self:
|
||||
if ntime is None:
|
||||
ntime = int(time())
|
||||
ntime = ntime + expires_time
|
||||
self._p_.setcache(path, props, ntime)
|
||||
return props
|
||||
|
||||
def append(self, propname):
|
||||
@ -387,9 +390,9 @@ class Settings(object):
|
||||
|
||||
def reset_cache(self, only_expired):
|
||||
if only_expired:
|
||||
self._p_.reset_expired_cache('property', time())
|
||||
self._p_.reset_expired_cache(int(time()))
|
||||
else:
|
||||
self._p_.reset_all_cache('property')
|
||||
self._p_.reset_all_cache()
|
||||
|
||||
def apply_requires(self, opt, path):
|
||||
"""carries out the jit (just in time) requirements between options
|
||||
|
Reference in New Issue
Block a user