Fetches from cache.
(
self,
key: str,
default: Any = None,
lazy: bool = True,
)
| 812 | raise exception.AppriseDiskIOError(str(e)) from None |
| 813 | |
| 814 | def get( |
| 815 | self, |
| 816 | key: str, |
| 817 | default: Any = None, |
| 818 | lazy: bool = True, |
| 819 | ) -> Any: |
| 820 | """Fetches from cache.""" |
| 821 | |
| 822 | if self._cache is None and not self.__load_cache(): |
| 823 | return default |
| 824 | |
| 825 | if ( |
| 826 | key in self._cache |
| 827 | and self.__mode != PersistentStoreMode.MEMORY |
| 828 | and not self.__dirty |
| 829 | ): |
| 830 | # ensure we renew our content |
| 831 | self.__renew.add(self.cache_file) |
| 832 | |
| 833 | return self._cache[key].value if self._cache.get(key) else default |
| 834 | |
| 835 | def set( |
| 836 | self, |