craft_parts.sources.cache module¶
Cache base and file cache.
- class craft_parts.sources.cache.FileCache(cache_dir, *, namespace='files')¶
Bases:
objectCache files based on the supplied key.
- Parameters:
cache_dir (
Path)namespace (
str)
- cache(*, filename, key)¶
Cache a file revision with hash in XDG cache, unless it already exists.
- Parameters:
filename (
str) – The path to the file to cache.key (
str) – The key to cache the file under.
- Return type:
Path|None- Returns:
The path to the cached file, or None if the file was not cached.
- clean()¶
Remove all files from the cache namespace.
- Return type:
None
- get(*, key)¶
Get the filepath which matches the hash calculated with algorithm.
- Parameters:
key (
str) – The key used to cache the file.- Return type:
Path|None- Returns:
The path to cached file, or None if the file is not cached.