buildgrid.server.cas.storage.index.index_abc module

IndexABC

The abstract base class for storage indices. An index is a special type of Storage that facilitates storing blob metadata. It must wrap another Storage.

Derived classes must implement all methods of both this interface and the StorageABC interface.

class buildgrid.server.cas.storage.index.index_abc.IndexABC(*, fallback_on_get: bool = False)

Bases: StorageABC

abstract least_recent_digests() Iterator[Digest]

Generator to iterate through the digests in LRU order

abstract get_total_size() int

Return the sum of the size of all blobs within the index.

abstract delete_n_bytes(n_bytes: int, dry_run: bool = False, protect_blobs_after: datetime | None = None, large_blob_threshold: int | None = None, large_blob_lifetime: datetime | None = None) int

Delete around n bytes of data from the index.

The ordering in which digests are deleted is up to the specific implementations and may provide different semantics such as LRU or random deletion. ALL implementations must respect the protect_blobs_after parameter to limit the age of deleted blobs

Implementations should generate delete around n_bytes on each call, but may delete more or less depending on the state of the storage, index, and value of protect_blobs_after.

Parameters:
  • n_bytes (int) – The number of bytes to be deleted

  • dry_run (bool) – Don’t actually delete any data, just return the number of bytes which would be deleted

  • protect_blobs_after – Don’t delete any digests which have been accessed after this time

  • large_blob_threshold (int) – Size in bytes for a blob to be considered ‘large’

  • large_blob_lifetime – Age after which ‘large’ blobs can be deleted.

Returns:

Number of bytes deleted