cache¶
Private Methods
Private methods, if any (those starting with _), are documented
for completeness but do not offer any stability guarantees.
They may change or be removed at any time without notice.
Polytropos cache management.
This module handles the Polytropos cache directory, including cleanup of
stale editable symlinks and full cache eviction via gc.
Defaults to /var/cache/polytropos/ when the process has write access to
it, $XDG_CACHE_HOME/polytropos/ otherwise, or ~/.cache/polytropos/
as fallback.
_cleanup_stale_symlinks(cache_base)
¶
Remove broken symlinks and empty dirs from the editable cache base.
Source code in src/polytropos/cache.py
_get_editable_cache_base()
¶
Get the base directory for editable install symlinks.
Resolution order:
1. POLYTROPOS_CACHE_DIR/editable/ (if POLYTROPOS_CACHE_DIR is set)
2. /var/cache/polytropos/editable/ (when writable)
3. XDG_CACHE_HOME/polytropos/editable/ (default)
4. ~/.cache/polytropos/editable/ (fallback)
Source code in src/polytropos/cache.py
_get_polytropos_cache_dir()
¶
Get the root Polytropos cache directory.
Resolution order:
1. POLYTROPOS_CACHE_DIR env var (explicit override)
2. /var/cache/polytropos/ (when writable — tries to create it)
3. XDG_CACHE_HOME/polytropos/ (default)
4. ~/.cache/polytropos/ (fallback)
Source code in src/polytropos/cache.py
_maybe_cleanup_stale_editables()
¶
Remove broken symlinks from the editable cache, at most once per hour.
A marker file .last_cleanup stores the ISO 8601 timestamp of the last run.
If the file is missing or older than 1 hour, scan all subdirectories of the
editable cache base and remove broken symlinks (and empty parent dirs).
Source code in src/polytropos/cache.py
gc(full=False)
¶
Garbage-collect the Polytropos cache.
See :func:_get_polytropos_cache_dir for the default cache directory
resolution order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full
|
bool
|
If True, delete the entire Polytropos cache directory. Otherwise, only remove broken symlinks from the editable cache. |
False
|