Cache module¶
Reference to the cache.py module.
cache
¶
Module with the cache interface and operations for working with dependencies.
| FUNCTION | DESCRIPTION |
|---|---|
get_cache |
Get general information about the cache, including number of dependencies and total size. |
clear_cache |
Delete the entire cache directory and recreate it empty. |
dep_cache_key |
Return a SHA-256 hex digest that uniquely identifies a single package. |
get_cached_dep |
Return the path to the cached per-package |
store_dep |
Store a per-package |
format_bytes |
Return a human-friendly string representation of a byte count. |
get_cache
¶
Gets general information about the cache.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
A dictionary containing information about the cache, such as the number of dependencies cached and the total size of the cache in bytes. |
Source code in nextmv-py/nextmv/nextmv/cache.py
clear_cache
¶
Delete the entire cache directory and recreate it empty.
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
A tuple of (num_deps_deleted, total_bytes_deleted). |
Source code in nextmv-py/nextmv/nextmv/cache.py
dep_cache_key
¶
Return a SHA-256 hex digest that uniquely identifies a single package wheel.
The key is derived from the normalised package name, version, target Python
version, and platform. Name normalisation follows PEP 503 so that
pydantic-core and pydantic_core map to the same key.
| PARAMETER | DESCRIPTION |
|---|---|
|
The package name as it appears in the lockfile or wheel filename.
TYPE:
|
|
The pinned version string (e.g.
TYPE:
|
|
The target Python version string (e.g.
TYPE:
|
|
The target platform string (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A 64-character lowercase hex SHA-256 digest. |
Source code in nextmv-py/nextmv/nextmv/cache.py
get_cached_dep
¶
Return the path to the cached installed.tar.gz for pkg_key, or None
on a miss.
The tarball contains the installed files for a single package archived under
.nextmv/python/deps/, ready to be concatenated with other per-package
tarballs to form the final deps.tar.gz (valid per RFC 1952).
On a cache hit last_used_at in the entry's cache_info.json is
updated to the current UTC time for LRU tracking.
| PARAMETER | DESCRIPTION |
|---|---|
|
The cache key returned by :func:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path or None
|
Path to the |
Source code in nextmv-py/nextmv/nextmv/cache.py
store_dep
¶
store_dep(
pkg_key: str,
tar_path: Path,
name: str,
version: str,
python_version: str,
platform: str,
max_entries: int = _MAX_DEPS,
max_bytes: int = _MAX_DEP_BYTES,
) -> None
Store a per-package installed.tar.gz in the cache and run LRU eviction.
The tarball must contain the installed files for a single package archived
under .nextmv/python/deps/. The copy is performed atomically via a
sibling temporary directory followed by a rename.
| PARAMETER | DESCRIPTION |
|---|---|
|
The cache key returned by :func:
TYPE:
|
|
Path to the
TYPE:
|
|
The package name (e.g.
TYPE:
|
|
The pinned version string (e.g.
TYPE:
|
|
The target Python version string (e.g.
TYPE:
|
|
The target platform string (e.g.
TYPE:
|
|
Maximum number of package tarball entries to retain.
TYPE:
|
|
Maximum total cache size in bytes.
TYPE:
|
Source code in nextmv-py/nextmv/nextmv/cache.py
format_bytes
¶
Return a human-friendly string representation of a byte count.
| PARAMETER | DESCRIPTION |
|---|---|
|
The size in bytes to format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A human-friendly string using B, KiB, MiB, or GiB units. |