Clear all cache files. If func is specified, clear cache for that specific function, otherwise clear the entire cache directory.
(func=None)
| 460 | |
| 461 | @staticmethod |
| 462 | def clear(func=None): |
| 463 | """Clear all cache files. |
| 464 | If func is specified, clear cache for that specific function, |
| 465 | otherwise clear the entire cache directory.""" |
| 466 | global cache_check_done, created_fns |
| 467 | |
| 468 | if func is not None: |
| 469 | fn_name = getfnname(func) |
| 470 | fn_cache_dir = f'{Cache.cache_directory}{fn_name}/' |
| 471 | cache_dir = relative_path(fn_cache_dir) |
| 472 | if os.path.exists(cache_dir): |
| 473 | rmtree(cache_dir, ignore_errors=True) |
| 474 | if fn_name in created_fns: |
| 475 | created_fns.remove(fn_name) |
| 476 | else: |
| 477 | cache_dir = relative_path(Cache.cache_directory) |
| 478 | if os.path.exists(cache_dir): |
| 479 | rmtree(cache_dir, ignore_errors=True) |
| 480 | cache_check_done = False |
| 481 | created_fns = set() |
| 482 | |
| 483 | # @staticmethod |
| 484 | # def delete_items_by_filter(func, items, should_delete_item): |
nothing calls this directly
no test coverage detected