LruActionCache(storage: buildgrid.server.cas.storage.storage_abc.StorageABC, max_cached_refs: int, allow_updates: bool = True, cache_failed_actions: bool = True)¶
In-memory Action Cache implementation with LRU eviction.
This cache has a configurable fixed size, evicting the least recently accessed entry when adding a new entry would exceed the fixed size. The cache is entirely stored in memory so its contents are lost on restart.
This type of cache is ideal for use cases that need a simple and fast cache, with no requirements for longevity of the cache content. It is not recommended to use this type of cache in situations where you may wish to obtain cached results a reasonable time in the future, due to its fixed size.
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 result for an Action.
If there is no cached result found, returns None.
action_digest (Digest) – The digest of the Action to retrieve the cached result of.
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 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.
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.