cache in dictionary storage

This commit is contained in:
2018-06-25 21:40:16 +02:00
parent f30ca3dc46
commit b10f02a8e9
6 changed files with 306 additions and 231 deletions

View File

@ -15,7 +15,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ____________________________________________________________
from time import time
from copy import copy
from logging import getLogger
import weakref
@ -337,27 +336,24 @@ class Settings(object):
# get properties and permissive methods
def get_context_properties(self):
ntime = int(time())
if self._p_.hascache(None,
None):
is_cached, props = self._p_.getcache(None,
ntime,
None)
else:
is_cached = False
if not is_cached or 'cache' not in props:
is_cached, props = self._p_.getcache(None,
None,
None,
None,
None,
'context_props')
if not is_cached:
meta = self._getcontext().cfgimpl_get_meta()
if meta is None:
props = self._p_.getproperties(None,
default_properties)
else:
props = meta.cfgimpl_get_settings().get_context_properties()
if 'cache' in props:
if 'expire' in props:
ntime = ntime + expires_time
else:
ntime = None
self._p_.setcache(None, props, ntime, None)
self._p_.setcache(None,
None,
props,
props,
None)
return props
def getproperties(self,
@ -371,19 +367,17 @@ class Settings(object):
if opt.impl_is_symlinkoption():
opt = opt.impl_getopt()
path = opt.impl_getpath(self._getcontext())
is_cached = False
if apply_requires and config_bag.setting_properties is not None:
if 'cache' in config_bag.setting_properties and \
'expire' in config_bag.setting_properties:
ntime = int(time())
else:
ntime = None
if 'cache' in config_bag.setting_properties and self._p_.hascache(path,
index):
is_cached, props = self._p_.getcache(path,
ntime,
index)
if apply_requires:
props = config_bag.setting_properties
is_cached, props = self._p_.getcache(path,
expires_time,
index,
props,
None,
'self_props')
else:
is_cached = False
if not is_cached:
meta = self._getcontext().cfgimpl_get_meta()
if meta is None:
@ -403,14 +397,12 @@ class Settings(object):
opt.impl_get_display_name())
props -= self.getpermissive(opt,
path)
if apply_requires and config_bag.setting_properties is not None and \
'cache' in config_bag.setting_properties:
if 'expire' in config_bag.setting_properties:
ntime = ntime + expires_time
if apply_requires:
self._p_.setcache(path,
index,
props,
ntime,
index)
config_bag.setting_properties,
config_bag.setting_properties)
return props
def get_context_permissive(self):
@ -599,6 +591,7 @@ class Settings(object):
"""save properties for specified path
(never save properties if same has option properties)
"""
# should have index !!!
if self._getcontext().cfgimpl_get_meta() is not None:
raise ConfigError(_('cannot change property with metaconfig'))
if path is not None and config_bag.option.impl_getrequires() is not None: