(allow_nonexist=True)
| 23 | return sum(global_cache_index.values()) |
| 24 | |
| 25 | def init_cache(allow_nonexist=True): |
| 26 | global global_cache |
| 27 | assert cache_path, "Need to set cache path" |
| 28 | |
| 29 | print(f"Cache path: {cache_path}") |
| 30 | |
| 31 | if not allow_nonexist: |
| 32 | assert os.path.exists(cache_path), f"{cache_path} does not exist" |
| 33 | |
| 34 | if os.path.exists(cache_path): |
| 35 | if cache_format == "pickle": |
| 36 | with open(cache_path, 'rb') as f: |
| 37 | global_cache = pickle.load(f) |
| 38 | elif cache_format == "json": |
| 39 | with open(cache_path, 'r') as f: |
| 40 | global_cache = json.load(f) |
| 41 | |
| 42 | def get_cache(key): |
| 43 | if key not in global_cache: |
nothing calls this directly
no outgoing calls
no test coverage detected