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
logging.basicConfig(level=logging.DEBUG)
async def main():
client = CacheCdnClient(
'http://cache-server.example.com:8300',
connection_per_cafs_server=10,
verbose_debug=True,
)
async with client:
await client.push('project_name', 'build_artifacts',
'/path/to/build/output', ttl_hours=2,
comment='Build artifacts from CI run #123',
compression=CompressionT.ZSTD)
exists = await client.check('project_name', 'build_artifacts')
print(f"Reference exists: {exists}")
await client.pull('project_name', 'build_artifacts',
'/path/to/destination')
await client.tag('project_name', 'build_artifacts', 'latest_stable')
await client.attach('project_name', 'build_artifacts',
Path('/path/to/metadata.json'))
await client.delete('project_name', 'old_artifacts')
if __name__ == '__main__':
asyncio.run(main())
API Reference
CacheCdnClient