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 serverconnection_per_cafs_server: Number of concurrent connections per CAFS serverlogger: Optional logger for custom loggingverbose_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 cachepull(repo: str, ref: str, directory: Path | str)- Pull cached content to a local directorycheck(repo: str, ref: str) -> bool- Check if a reference existstag(repo: str, ref: str, tag: str)- Create a tag for a referenceattach(repo: str, ref: str, file_path: Path)- Attach a file to an existing referencedelete(repo: str, ref: str)- Delete a reference
Metadata
Release files for cafs-cache-cdn-client 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cafs_cache_cdn_client-1.1.0.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cafs_cache_cdn_client-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.0 kB
Release files / cafs_cache_cdn_client-1.1.0.tar.gz
| Download URL | cafs_cache_cdn_client-1.1.0.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0dbc109ae0efd26addc78dbb7b7d5d1ea3ff3fdd00d013791360c3ebfc0a637e
|
|
BLAKE2b-256 checksum How to use checksums |
4cdce82fa83d46b669bd4374ddcdebbe8b7f7c7b88686c4258a4d9b9ecd9bbea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / cafs_cache_cdn_client-1.1.0-py3-none-any.whl
| Download URL | cafs_cache_cdn_client-1.1.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ac91607dc0ab94271463f41ea459dff20ab1163ce279b3792266c7537ab2104
|
|
BLAKE2b-256 checksum How to use checksums |
b0f9f84344123525afb88e2a8477d531b9fd4d45d931af2006ad8650e7959936
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|