Skip to main content

Cache CDN Client

A Python client library for interacting with the Cache CDN service based on CAFS, allowing efficient pushing and pulling of cached content.

Installation

pip install cafs-cache-cdn-client

Features

  • Asynchronous API for high-performance operations
  • Push local directories to cache
  • Pull cached content to local directories
  • Check existence of cached references
  • Tag references for easier access
  • Attach additional files to existing references
  • Delete references when no longer needed

Usage Example

import asyncio
import logging
from pathlib import Path
from cafs_cache_cdn_client import CacheCdnClient, CompressionT

# Configure logging to see detailed operation information
logging.basicConfig(level=logging.DEBUG)


async def main():
    # Initialize the client with the server URL
    # The connection_per_cafs_server parameter controls concurrency
    client = CacheCdnClient(
        'http://cache-server.example.com:8300',
        connection_per_cafs_server=10,
        verbose_debug=True,
    )

    # Use as an async context manager to ensure proper resource cleanup
    async with client:
        # Push a local directory to cache with a 2-hour TTL and preferred ZSTD compression
        await client.push('project_name', 'build_artifacts',
                          '/path/to/build/output', ttl_hours=2,
                          comment='Build artifacts from CI run #123',
                          compression=CompressionT.ZSTD)

        # Check if a reference exists
        exists = await client.check('project_name', 'build_artifacts')
        print(f"Reference exists: {exists}")

        # Pull cached content to a local directory
        await client.pull('project_name', 'build_artifacts',
                          '/path/to/destination')

        # Tag a reference for easier access later
        await client.tag('project_name', 'build_artifacts', 'latest_stable')

        # Attach an additional file to an existing reference
        await client.attach('project_name', 'build_artifacts',
                            Path('/path/to/metadata.json'))

        # Delete a reference when no longer needed
        await client.delete('project_name', 'old_artifacts')


# Run the example
if __name__ == '__main__':
    asyncio.run(main())

API Reference

CacheCdnClient

  • Constructor: CacheCdnClient(server: str, connection_per_cafs_server: int = 1)

    • server: URL of the cache server
    • connection_per_cafs_server: Number of concurrent connections per CAFS server
    • logger: Optional logger for custom logging
    • verbose_debug: Enable verbose debug logging (default: False)
  • Methods:

    • push(repo: str, ref: str, directory: Path | str, ttl_hours: int = 0, comment: str | None = None, compression: CompressionT = CompressionT.NONE) - Push a local directory to cache
    • pull(repo: str, ref: str, directory: Path | str, *, delete_unlisted: bool = True, verify_existing: bool = True) - Pull cached content to a local directory. With delete_unlisted=False, local files the ref does not list are kept and the directory is not scanned. With verify_existing=False, files that the ref lists and that already exist are not hashed or modified, so their content is not guaranteed to match the ref
    • check(repo: str, ref: str) -> bool - Check if a reference exists
    • tag(repo: str, ref: str, tag: str) - Create a tag for a reference
    • attach(repo: str, ref: str, file_path: Path) - Attach a file to an existing reference
    • delete(repo: str, ref: str) - Delete a reference

Metadata

Release files for cafs-cache-cdn-client 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cafs-cache-cdn-client 1.2.0
File Size Uploaded Provenance Actions
cafs_cache_cdn_client-1.2.0.tar.gz 14.8 kB Without provenance Details for cafs_cache_cdn_client-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cafs-cache-cdn-client 1.2.0
File Interpreter ABI Platform Actions
cafs_cache_cdn_client-1.2.0-py3-none-any.whl Python 3 none any Details for cafs_cache_cdn_client-1.2.0-py3-none-any.whl

Total release size: 34.8 kB

Release files / cafs_cache_cdn_client-1.2.0.tar.gz

Download URL cafs_cache_cdn_client-1.2.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f1a1cd464faa2327db976a77a7447790439cd60b21a9fbf1783cdf49d6f74d57
BLAKE2b-256 checksum
How to use checksums
83e5a27d08985c57ae0fc87181563c72f2915f9e862d5853490a2ded48723d5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cafs_cache_cdn_client-1.2.0-py3-none-any.whl

Download URL cafs_cache_cdn_client-1.2.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19abc0aa55b7b0766c4085cb99c9e4aa87bc1b677924aa4ac64295e9d8b5d936
BLAKE2b-256 checksum
How to use checksums
99271fefb17d61fbc0bf8b074b8a26c7df8b2bc65211afa4016787d63994c5c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for cafs-cache-cdn-client 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page