(self, cache_key, value)
| 3971 | raise KeyError(cache_key) |
| 3972 | |
| 3973 | def __setitem__(self, cache_key, value): |
| 3974 | full_key = self._convert_cache_key(cache_key) |
| 3975 | try: |
| 3976 | file_content = self._dumps(value) |
| 3977 | except (TypeError, ValueError): |
| 3978 | raise ValueError( |
| 3979 | f"Value cannot be cached, must be " |
| 3980 | f"JSON serializable: {value}" |
| 3981 | ) |
| 3982 | if not os.path.isdir(self._working_dir): |
| 3983 | os.makedirs(self._working_dir) |
| 3984 | with os.fdopen( |
| 3985 | os.open(full_key, os.O_WRONLY | os.O_CREAT, 0o600), 'w' |
| 3986 | ) as f: |
| 3987 | f.truncate() |
| 3988 | f.write(file_content) |
| 3989 | |
| 3990 | def _convert_cache_key(self, cache_key): |
| 3991 | full_path = os.path.join(self._working_dir, cache_key + '.json') |
nothing calls this directly
no test coverage detected