Skip to main content

Module cache

Module cache 

Source
Expand description

Shared binary cache for PostgreSQL downloads.

This module provides caching infrastructure to avoid repeated downloads of PostgreSQL binaries when multiple tests or processes need the same version. Binaries are stored in a user-specific cache directory and shared across test runs.

§Cache Location

The cache directory is resolved by resolve_cache_dir in the following order:

  1. PG_BINARY_CACHE_DIR environment variable if set
  2. $XDG_CACHE_HOME/pg-embedded/binaries if XDG_CACHE_HOME is set
  3. ~/.cache/pg-embedded/binaries if the home directory is available
  4. /tmp/pg-embedded/binaries as last resort when none of the above are available

§Cross-Process Coordination

The cache uses file-based locking to coordinate downloads across parallel test runners. Locks are per-version, allowing different versions to be downloaded concurrently.

Structs§

BinaryCacheConfig
Configuration for the shared binary cache.
CacheLock
Guard that holds a file lock until dropped.

Enums§

CacheLookupResult
Result of a cache lookup operation.

Functions§

check_cache
Checks if the cache contains valid binaries for the given version.
copy_from_cache
Copies cached binaries to the target installation directory.
find_matching_cached_version
Finds a cached version that satisfies the given version requirement.
populate_cache
Populates the cache with binaries from the given source directory.
resolve_cache_dir
Resolves the binary cache directory from environment and XDG conventions.
try_populate_cache
Attempts to populate the cache after a download, logging warnings on failure.
try_use_cache
Attempts to use the cache, falling back gracefully on errors.