mirror of https://github.com/fmartingr/iosfu.git
Backups use/store cache based on the data variable cache.enabled
This commit is contained in:
parent
577b10273a
commit
42671f9764
|
@ -39,14 +39,23 @@ class BasePlugin(object):
|
||||||
Main function called by plugin library.
|
Main function called by plugin library.
|
||||||
"""
|
"""
|
||||||
if self._backup:
|
if self._backup:
|
||||||
cached = self._backup.cache(self.__slug__)
|
|
||||||
if cached is None:
|
# Load from cache if enabled
|
||||||
result = self.__do__(*args, **kwargs)
|
if self._backup.data('cache.enabled'):
|
||||||
|
cached = self._backup.cache(self.__slug__)
|
||||||
|
if cached is not None:
|
||||||
|
return cached
|
||||||
|
|
||||||
|
# Not found in cache, execute plugin!
|
||||||
|
result = self.__do__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Save to cache if enabled
|
||||||
|
if self._backup.data('cache.enabled'):
|
||||||
self._backup.cache(self.__slug__, result)
|
self._backup.cache(self.__slug__, result)
|
||||||
self._backup.write_data_file()
|
self._backup.write_data_file()
|
||||||
return result
|
|
||||||
else:
|
# Return result
|
||||||
return cached
|
return result
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Plugin {0} need a backup instance to work with'.format(
|
'Plugin {0} need a backup instance to work with'.format(
|
||||||
|
|
Loading…
Reference in New Issue