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)
| 185 | return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key)) |
| 186 | |
| 187 | def get(self, key: str, default): |
| 188 | class="st">"""Return the cached value for the given key. |
| 189 | |
| 190 | If no value was yet cached or the value cannot be read, the specified |
| 191 | default is returned. |
| 192 | |
| 193 | :param key: |
| 194 | Must be a ``/`` separated value. Usually the first |
| 195 | name is the name of your plugin or your application. |
| 196 | :param default: |
| 197 | The value to return in case of a cache-miss or invalid cache value. |
| 198 | class="st">""" |
| 199 | path = self._getvaluepath(key) |
| 200 | try: |
| 201 | with path.open(class="st">"r", encoding=class="st">"UTF-8") as f: |
| 202 | return json.load(f) |
| 203 | except (ValueError, OSError): |
| 204 | return default |
| 205 | |
| 206 | def set(self, key: str, value: object) -> None: |
| 207 | class="st">"""Save value for the given key. |
no test coverage detected