buildgrid.server.actioncache.caches.sharded_cache module
- class buildgrid.server.actioncache.caches.sharded_cache.ShardedActionCache(shards: dict[str, buildgrid.server.actioncache.caches.action_cache_abc.ActionCacheABC], allow_updates: bool = True, cache_failed_actions: bool = True, cache_key_salt: str | None = None)
Bases:
ActionCacheABC
This is a wrapper intended to be used to compose an Action Cache of multiple other Action Caches, e.g. for sharding a Redis Action Cache.
Requests are forwarded on to a specific shard based on the shard name, instance name, and Action Digest.
- start() None
- stop() None
- get_action_result(action_digest: Digest) ActionResult
Retrieves the cached result for an Action.
Determines the expected shard, and attempts to retrieve the ActionResult from that shard. If the result is not found, a NotFoundError is raised.
- Parameters:
action_digest (Digest) – The digest of the Action to retrieve the cached result of.
- update_action_result(action_digest: Digest, action_result: ActionResult) None
Stores a result for an Action in the cache.
Determines which shard a result should be stored in, and attempts to store it. If the result has a non-zero exit code and cache_failed_actions is False for either this shard or the whole 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.