buildgrid.server.actioncache.caches.write_once_cache module

Write Once Action Cache

An ActionCache backend implementation which only allows each digest to be written to once. Any subsequent requests to cache a result for the same digests will not be permitted.

This can be used to wrap a different ActionCache implementation to provide immutability of cache results.

class buildgrid.server.actioncache.caches.write_once_cache.WriteOnceActionCache(action_cache: buildgrid.server.actioncache.caches.action_cache_abc.ActionCacheABC)

Bases: buildgrid.server.actioncache.caches.action_cache_abc.ActionCacheABC

property allow_updates
get_action_result(action_digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest) → build.bazel.remote.execution.v2.remote_execution_pb2.ActionResult

Retrieves the cached ActionResult for the given Action digest.

Parameters

action_digest (Digest) – The digest of the Action to retrieve the cached result of.

Returns

The cached ActionResult matching the given digest or raises NotFoundError.

update_action_result(action_digest: build.bazel.remote.execution.v2.remote_execution_pb2.Digest, action_result: build.bazel.remote.execution.v2.remote_execution_pb2.ActionResult) → None

Stores the result for a given digest in the cache.

If the digest already exists in the cache, then an UpdateNotAllowedError is raised instead of storing the result.

Parameters
  • action_digest (Digest) – The digest of the Action whose result is being cached.

  • action_result (ActionResult) – The result to cache for the given Action digest.