buildgrid.server.cas.storage.index.redis module
A storage provider that uses redis to maintain existence and expiry metadata for a storage.
- class buildgrid.server.cas.storage.index.redis.RedisIndex(redis: RedisProvider, storage: StorageABC)
Bases:
IndexABC
- TYPE: str = 'RedisIndex'
- start() None
- stop() None
- has_blob(digest: Digest) bool
Return True if the blob with the given instance/digest exists.
- get_blob(digest: Digest) IO[bytes] | None
Return a file-like object containing the blob. Most implementations will read the entire file into memory and return a BytesIO object. Eventually this should be corrected to handle files which cannot fit into memory.
The file-like object must be readable and seekable.
If the blob isn’t present in storage, return None.
- delete_blob(digest: Digest) None
Delete the blob from storage if it’s present.
- commit_write(digest: Digest, write_session: IO[bytes]) None
Store the contents for a digest.
The storage object is not responsible for verifying that the data written to the write_session actually matches the digest. The caller must do that.
- bulk_delete(digests: list[buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2.Digest]) list[str]
Delete a list of blobs from storage.
- missing_blobs(digests: list[buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2.Digest]) list[buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2.Digest]
Return a container containing the blobs not present in CAS.
- bulk_update_blobs(blobs: list[tuple[buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2.Digest, bytes]]) list[buildgrid._protos.google.rpc.status_pb2.Status]
Given a container of (digest, value) tuples, add all the blobs to CAS. Return a list of Status objects corresponding to the result of uploading each of the blobs.
Unlike in commit_write, the storage object will verify that each of the digests matches the provided data.
- bulk_read_blobs(digests: list[buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2.Digest]) dict[str, bytes]
Given an iterable container of digests, return a {hash: file-like object} dictionary corresponding to the blobs represented by the input digests.
Each file-like object must be readable and seekable.
- least_recent_digests() Iterator[Digest]
Generator to iterate through the digests in LRU order
- get_total_size() int
Return the sum of the size of all blobs within the index
- 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
Iterate through the Redis Index using ‘SCAN’ and delete any entries older than ‘protect_blobs_after’. The ordering of the deletes is undefined and can’t be assumed to be LRU. Large blobs can optionally be configured to have a separate lifetime.