buildgrid.server.actioncache.instance module

Action Cache

Implements an in-memory action Cache

class buildgrid.server.actioncache.instance.ActionCache(cache: ActionCacheABC)

Bases: Instance

SERVICE_NAME: ClassVar[str] = 'build.bazel.remote.execution.v2.ActionCache'

The expected FULL_NAME of the Service which will wrap this instance. This value should be declared on the class of any Instance implementations.

start() None

A method called when the grpc service is starting.

This method may be overriden if startup logic is required.

stop() None

A method called when the grpc service is shutting down.

This method may be overriden if shutdown logic is required.

property allow_updates: bool
hash_type() int
set_instance_name(instance_name: str) None

Set the instance name associated with this instance. This method may be overriden if extra referencing is required.

Parameters:

instance_name (str) – The new instance’s name.

Raises:

AssertionError – if the instance is already registered.

get_action_ignored_exceptions = (<class 'buildgrid._exceptions.NotFoundError'>, <class 'buildgrid._exceptions.RetriableError'>)
get_action_result(action_digest: Digest) ActionResult

Retrieves the cached result for an Action.

If there is no cached result found, returns None.

Parameters:

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

update_action_ignored_exceptions = (<class 'buildgrid._exceptions.NotFoundError'>, <class 'buildgrid._exceptions.RetriableError'>)
update_action_result(action_digest: Digest, action_result: ActionResult) None

Stores a result for an Action in the cache.

If the result has a non-zero exit code and cache_failed_actions is False for this cache, the result is not cached.

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.