Dump a Resource to the disk cache.
(self, resource)
| 918 | self.resources_by_path[path] = resource |
| 919 | |
| 920 | def _dump_resource(self, resource): |
| 921 | """ |
| 922 | Dump a Resource to the disk cache. |
| 923 | """ |
| 924 | cache_location = resource.cache_location |
| 925 | |
| 926 | if not cache_location: |
| 927 | raise TypeError( |
| 928 | f"Resource cannot be dumped to disk and is used onlyin memory: {resource}" |
| 929 | ) |
| 930 | |
| 931 | # TODO: consider messagepack or protobuf for compact/faster processing? |
| 932 | with open(cache_location, "w") as cached: |
| 933 | cached.write(json.dumps(resource.serialize(), check_circular=False)) |
| 934 | |
| 935 | # TODO: consider adding a small LRU cache in front of this for perf? |
| 936 | def _load_resource(self, path): |
no test coverage detected