# 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
``` bash
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
```python
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
Raw data
{
"_id": null,
"home_page": null,
"name": "cafs-cache-cdn-client",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "cafs, cache",
"author": "Konstantin Belov",
"author_email": "k.belov@gaijin.team",
"download_url": "https://files.pythonhosted.org/packages/9c/61/bedee2f6b26c079ce253fc544560ef80de5946c9ea34ec1b394fc56362ff/cafs_cache_cdn_client-1.0.11.tar.gz",
"platform": null,
"description": "# Cache CDN Client\nA Python client library for interacting with the Cache CDN service based on CAFS, allowing efficient pushing and pulling of cached content.\n## Installation\n``` bash\npip install cafs-cache-cdn-client\n```\n## Features\n- Asynchronous API for high-performance operations\n- Push local directories to cache\n- Pull cached content to local directories\n- Check existence of cached references\n- Tag references for easier access\n- Attach additional files to existing references\n- Delete references when no longer needed\n\n## Usage Example\n```python\nimport asyncio\nimport logging\nfrom pathlib import Path\nfrom cafs_cache_cdn_client import CacheCdnClient, CompressionT\n\n# Configure logging to see detailed operation information\nlogging.basicConfig(level=logging.DEBUG)\n\n\nasync def main():\n # Initialize the client with the server URL\n # The connection_per_cafs_server parameter controls concurrency\n client = CacheCdnClient(\n 'http://cache-server.example.com:8300',\n connection_per_cafs_server=10,\n verbose_debug=True,\n )\n\n # Use as an async context manager to ensure proper resource cleanup\n async with client:\n # Push a local directory to cache with a 2-hour TTL and preferred ZSTD compression\n await client.push('project_name', 'build_artifacts',\n '/path/to/build/output', ttl_hours=2,\n comment='Build artifacts from CI run #123',\n compression=CompressionT.ZSTD)\n\n # Check if a reference exists\n exists = await client.check('project_name', 'build_artifacts')\n print(f\"Reference exists: {exists}\")\n\n # Pull cached content to a local directory\n await client.pull('project_name', 'build_artifacts',\n '/path/to/destination')\n\n # Tag a reference for easier access later\n await client.tag('project_name', 'build_artifacts', 'latest_stable')\n\n # Attach an additional file to an existing reference\n await client.attach('project_name', 'build_artifacts',\n Path('/path/to/metadata.json'))\n\n # Delete a reference when no longer needed\n await client.delete('project_name', 'old_artifacts')\n\n\n# Run the example\nif __name__ == '__main__':\n asyncio.run(main())\n```\n\n## API Reference\n### `CacheCdnClient`\n- **Constructor**: `CacheCdnClient(server: str, connection_per_cafs_server: int = 1)`\n - `server`: URL of the cache server\n - `connection_per_cafs_server`: Number of concurrent connections per CAFS server\n - `logger`: Optional logger for custom logging\n - `verbose_debug`: Enable verbose debug logging (default: `False`)\n\n- **Methods**:\n - `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\n - `pull(repo: str, ref: str, directory: Path | str)` - Pull cached content to a local directory\n - `check(repo: str, ref: str) -> bool` - Check if a reference exists\n - `tag(repo: str, ref: str, tag: str)` - Create a tag for a reference\n - `attach(repo: str, ref: str, file_path: Path)` - Attach a file to an existing reference\n - `delete(repo: str, ref: str)` - Delete a reference\n",
"bugtrack_url": null,
"license": null,
"summary": "Async Cache CDN client implementation",
"version": "1.0.11",
"project_urls": null,
"split_keywords": [
"cafs",
" cache"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f7c3005515153fc2cbc996e3a45bfdb1f1eb5139f091f48b06e925b46cca8583",
"md5": "5430c923bce3d669460f62c4f8c06098",
"sha256": "43e02b70cd102a7825db876062eee4cd73a930181b77358c0d02d0634662ad6b"
},
"downloads": -1,
"filename": "cafs_cache_cdn_client-1.0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5430c923bce3d669460f62c4f8c06098",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 17894,
"upload_time": "2025-07-16T13:33:27",
"upload_time_iso_8601": "2025-07-16T13:33:27.637375Z",
"url": "https://files.pythonhosted.org/packages/f7/c3/005515153fc2cbc996e3a45bfdb1f1eb5139f091f48b06e925b46cca8583/cafs_cache_cdn_client-1.0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9c61bedee2f6b26c079ce253fc544560ef80de5946c9ea34ec1b394fc56362ff",
"md5": "e145e6cebad1d93b38f8fb645613758d",
"sha256": "03e756dde00803b296c659cffd1cbf39b2dc553e3860b8810880cb489e63b194"
},
"downloads": -1,
"filename": "cafs_cache_cdn_client-1.0.11.tar.gz",
"has_sig": false,
"md5_digest": "e145e6cebad1d93b38f8fb645613758d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 13721,
"upload_time": "2025-07-16T13:33:29",
"upload_time_iso_8601": "2025-07-16T13:33:29.079640Z",
"url": "https://files.pythonhosted.org/packages/9c/61/bedee2f6b26c079ce253fc544560ef80de5946c9ea34ec1b394fc56362ff/cafs_cache_cdn_client-1.0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-16 13:33:29",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cafs-cache-cdn-client"
}