Skip to content

Installation

Requirements

Component Supported configuration
Python Standard CPython 3.14+; free-threaded builds are unsupported
PyMongo 4.18.1 or newer
Package platform Linux x86-64 or ARM64 with glibc 2.28+; other platforms are unsupported
Shared-cache host Linux 5.1+ with memfd sealing and /proc available
MongoDB caching MongoDB 8.0+ on a replica set or sharded cluster
Database access Collection reads and metadata (listCollections, plus listIndexes for unique-key discovery), and database-level changeStream access

Binary wheels include the Rust native module, which uses profile-guided optimization. Source builds use link-time optimization without profile guidance, so their performance may differ. They require Rust and Cargo and are tested only with the stable Rust release that the package selects. With rustup, the build installs and uses that release automatically.

For shared caching, also review the owner and worker security requirements.

On reachable standalone MongoDB servers or versions below the minimum, reads run through PyMongo without caching. The manager logs a warning when it cannot establish a database change stream; see stream health. Uncached reads still require a reachable server that can serve the operation; a missing server can raise PyMongo's ServerSelectionTimeoutError.

Install

uv add client-query-cache

Or install with pip:

pip install client-query-cache

For optional telemetry, install client-query-cache[otel] and follow Monitoring.

Verify release provenance

The source distribution and wheels of each release published after 0.12.0 carry signed SLSA Build Level 2 provenance created by GitHub Actions. Release 0.12.0 and earlier releases have none.

Verification needs the GitHub CLI, signed in to a GitHub account with gh auth login even for this public repository (cli/cli#11803). Replace X.Y.Z with the release you downloaded:

pip download client-query-cache==X.Y.Z --no-deps -d dist
gh attestation verify dist/client_query_cache-X.Y.Z-*.whl --repo alessio-locatelli/client-query-cache --signer-workflow alessio-locatelli/client-query-cache/.github/workflows/publish.yml --source-ref refs/tags/vX.Y.Z --deny-self-hosted-runners

Success proves that the publishing workflow of this repository signed the file for that tag and commit on a GitHub-hosted signing runner, and that the signature is recorded in a public transparency log. The workflow at that commit defines the GitHub-hosted build runners and can be inspected.

It does not prove that the code is free of defects or vulnerabilities, that the workflow and source at that commit are trustworthy, or that the tag was never moved to another commit. The release procedure, not verification, prevents moved tags.

Dependency upgrades

Deploy from a lockfile or pinned dependency set; see uv locking and syncing or Poetry's lockfile guidance.

Test PyMongo upgrades, including patch releases, against your application's cached hits, misses, cursor consumption, session bypass, startup, shutdown and recovery. The integration depends on driver behavior beyond query signatures.

Local MongoDB

The repository’s docker-compose.yaml provides an example single-member replica set for local development. From a repository checkout, run:

docker compose -f development/docker-compose.yaml --project-directory . up -d mongo
docker compose -f development/docker-compose.yaml --project-directory . run --rm mongo_helper

The helper initializes the replica set if needed and waits until it is writable. When it exits successfully, the tutorials can connect to mongodb://localhost:27017. They write to the client_query_cache_tutorial database. This setup is for local evaluation; see deployment guidance for application deployments.

Stop the local services with:

docker compose -f development/docker-compose.yaml --project-directory . down

See the official Docker Compose documentation for tool installation and usage.

For disposable test databases in GitLab CI or GitHub Actions, see MongoDB in CI.