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) - Pull cached content to a local directory
    • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cafs_cache_cdn_client-1.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cafs_cache_cdn_client-1.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file cafs_cache_cdn_client-1.1.0.tar.gz.

File metadata

  • Download URL: cafs_cache_cdn_client-1.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cafs_cache_cdn_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0dbc109ae0efd26addc78dbb7b7d5d1ea3ff3fdd00d013791360c3ebfc0a637e
MD5 2c0ce0340968190119f6be8a3c7a23d0
BLAKE2b-256 4cdce82fa83d46b669bd4374ddcdebbe8b7f7c7b88686c4258a4d9b9ecd9bbea

See more details on using hashes here.

File details

Details for the file cafs_cache_cdn_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cafs_cache_cdn_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cafs_cache_cdn_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac91607dc0ab94271463f41ea459dff20ab1163ce279b3792266c7537ab2104
MD5 0775a1bbbc82703ed5db68bf6deccba2
BLAKE2b-256 b0f9f84344123525afb88e2a8477d531b9fd4d45d931af2006ad8650e7959936

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page