Compare commits

..

No commits in common. "9a1fa9e0ab586f228b5614747a1953f36fb03793" and "ed1082041f8b7940e5ed6238eead2b97a5b3e862" have entirely different histories.

3 changed files with 3791 additions and 4030 deletions

View File

@ -142,24 +142,16 @@ class property_cache_pickle(object):
:param default: value to be returned, if key does not exists.
:returns: value for a given key or default value.
"""
# Init cache
if key in self._source_instance.keys() and key not in self._source_get_keys:
if self._cached_props is None:
self._init_cache()
# Identify old cache
if self._max_age is None:
cache_old = False
else:
cache_old = time.time() - self._cached_props[self.AGE_TAG].get(self._key_filter(key), 0) > self._max_age
if cache_old:
logger.debug("The cached value is old, cached value will be ignored")
# Return cached value
if not cache_old and key not in self._source_get_keys and self._key_filter(key) in self._cached_props[self.DATA_TAG]:
logger.debug("Providing property for '%s' from cache", key)
rv = self._cached_props[self.DATA_TAG].get(self._key_filter(key), default)
if rv is not None or not self._return_source_on_none:
return rv
# Create cache and return value
if key in self._source_instance.keys():
if self._key_filter(key) not in self._cached_props[self.DATA_TAG] or cache_old:
logger.debug("Loading property for key='%s' from source instance", key)
val = self._source_instance.get(key, None)
if self._store_on_get:
@ -170,6 +162,8 @@ class property_cache_pickle(object):
self._save_cache()
else:
return val
else:
logger.debug("Providing property for '%s' from cache", key)
cached_data = self._cached_props[self.DATA_TAG].get(self._key_filter(key), default)
if cached_data is None and self._return_source_on_none:
return self._source_instance.get(key, default)

File diff suppressed because it is too large Load Diff

Binary file not shown.