Caches and upload sources

Builders keep layer history, upload results, and URL-download metadata in one Store. Helpers and direct builders accept store=. Tree kinds separate reusable records from user sessions. Node data contains JSON values. See Build a Docker image, Tree stores, and Reuse uploads and retain their sources for retention, connection scope, and upload provenance.

Upload reuse through the public file-transfer and store contracts.

class contree_sdk.upload_cache.AsyncCachedFileTransfer(transfer, store, *, scope, ttl, sources=None)[source]

Cache content uploads; apply permissions from each current request.

ttl is required and measured from upload completion. Hits do not renew it. Concurrent misses may upload the same content. The caller owns all components.

async download_file(image_uuid, path, destination)

Atomically save streamed content.

Return type:

int

Returns:

The number of downloaded bytes.

iter_file(image_uuid, path)[source]

Yield file content. Override this buffered fallback for streaming backends.

Yields:

File content chunks. Close the generator if iteration stops early.

Return type:

AsyncGenerator[bytes, None]

class contree_sdk.upload_cache.CachedFileTransfer(transfer, store, *, scope, ttl, sources=None)[source]

Cache content uploads; apply permissions from each current request.

ttl is required and measured from upload completion. Hits do not renew it. Concurrent misses may upload the same content. The caller owns all components.

download_file(image_uuid, path, destination)

Atomically save streamed content.

Return type:

int

Returns:

The number of downloaded bytes.

iter_file(image_uuid, path)[source]

Yield file content. Override this buffered fallback for streaming backends.

Yields:

File content chunks. Close the generator if iteration stops early.

Return type:

Generator[bytes, None, None]

class contree_sdk.upload_cache.UploadSnapshot(file, sha256, source=None, directory=None)[source]

Source records kept in a separate namespace from upload store entries.

class contree_sdk.file_sources.AsyncFileSources(store, scope, *, clock=<built-in function time>)[source]

Source registry backed by records with implementation-defined retention in a caller-owned store.

Upload invalidation does not remove source records. A source is provenance, not proof that the remote upload still exists or that the local file is unchanged.

class contree_sdk.file_sources.FileSource(file_uuid, sha256, source, kind, recorded_at)[source]
class contree_sdk.file_sources.SyncFileSources(store, scope, *, clock=<built-in function time>)[source]

Source registry backed by records with implementation-defined retention in a caller-owned store.

Upload invalidation does not remove source records. A source is provenance, not proof that the remote upload still exists or that the local file is unchanged.

Bind cache namespaces to a server and an authorization context.

class contree_sdk.scope.StoreScope(digest)[source]

A non-secret digest separating endpoint, project, credential, and profile.

classmethod from_client(client, *, profile='')[source]

Derive a scope without storing credentials in cache keys or records.

Return type:

StoreScope

Returns:

A scope that changes when endpoint, project, credential, or profile changes.