Return the cached value for the given key. If no value was yet cached or the value cannot be read, the specified default is returned. :param key: Must be a ``/`` separated value. Usually the first name is the name of your plugin or your application.
(self, key: str, default)
| 144 | return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key)) |
| 145 | |
| 146 | def get(self, key: str, default): |
| 147 | """Return the cached value for the given key. |
| 148 | |
| 149 | If no value was yet cached or the value cannot be read, the specified |
| 150 | default is returned. |
| 151 | |
| 152 | :param key: |
| 153 | Must be a ``/`` separated value. Usually the first |
| 154 | name is the name of your plugin or your application. |
| 155 | :param default: |
| 156 | The value to return in case of a cache-miss or invalid cache value. |
| 157 | """ |
| 158 | path = self._getvaluepath(key) |
| 159 | try: |
| 160 | with path.open("r") as f: |
| 161 | return json.load(f) |
| 162 | except (ValueError, OSError): |
| 163 | return default |
| 164 | |
| 165 | def set(self, key: str, value: object) -> None: |
| 166 | """Save value for the given key. |
no test coverage detected