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 delete_blob(digest: Digest) None

Delete a blob from the index. Return True if the blob was deleted, or False otherwise.

TODO: This method will be promoted to StorageABC in a future commit.

abstract least_recent_digests() Iterator[Digest]

Generator to iterate through the digests in LRU order

abstract get_total_size(include_marked: bool = True) int

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

If include_marked is True, it will also include the size of blobs that have been marked deleted.

abstract delete_n_bytes(n_bytes: int, dry_run: bool = False, protect_blobs_after: 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

Returns:

Number of bytes deleted