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: ActionCacheABC)

Bases: ActionCacheABC

start() None
stop() None
property allow_updates: bool
get_action_result(action_digest: Digest) 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: Digest, action_result: 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.