跳到主要内容

_cache

TOC

Functions

🅵 _clear_cache

_clear_cache
def _clear_cache(cache_dir: str) -> None:
if os.path.exists(cache_dir):
import shutil

shutil.rmtree(cache_dir)
logger.info("Cache dir {} has been cleared!", cache_dir)
else:
logger.warning("Cache dir {} does not exist", cache_dir)

🅵 clear_cache

clear_cache
@app.command()
def clear_cache() -> None:
if not typer.confirm(
f"Are you sure you want to clear cache of {workspace.name}? Cache dir is {workspace.cache_dir}."
):
return
_clear_cache(workspace.cache_dir)

Remove the cache folder which belongs to current workspace.

🅵 clear_all_cache

clear_all_cache
@app.command()
def clear_all_cache() -> None:
if not os.path.exists(workspace.cache_base_dir):
logger.warning("Cache dir {} does not exist", workspace.cache_base_dir)
return
print(_create_table("Cache Names", os.listdir(workspace.cache_base_dir)))
if not typer.confirm("Are you sure you want to clear all cache?"):
return
_clear_cache(workspace.cache_base_dir)

Remove the whole cache folder.

🅵 cache_list

@app.command()
def cache_list() -> None:
table = _create_table("Cache Names", os.listdir(workspace.cache_base_dir))
logger.info(table)

Show cache folders.

🅵 cache_dir

@app.command()
def cache_dir() -> None:
print(workspace.cache_dir)

Show current cache folders.