Skip to content
Snippets Groups Projects
Commit 42688690 authored by Martin Blanchard's avatar Martin Blanchard
Browse files

actioncache/storage.py: Log cache update events

parent 17730051
No related branches found
No related tags found
Loading
......@@ -20,22 +20,39 @@ Action Cache
Implements an in-memory action Cache
"""
import logging
from ..referencestorage.storage import ReferenceCache
class ActionCache(ReferenceCache):
def __init__(self, storage, max_cached_refs, allow_updates=True):
super().__init__(storage, max_cached_refs, allow_updates)
self.__logger = logging.getLogger(__name__)
# --- Public API ---
def register_instance_with_server(self, instance_name, server):
server.add_action_cache_instance(self, instance_name)
def get_action_result(self, action_digest):
"""Retrieves the cached result for an action."""
key = self._get_key(action_digest)
return self.get_action_reference(key)
def update_action_result(self, action_digest, action_result):
"""Stores in cache a result for an action."""
key = self._get_key(action_digest)
self.update_reference(key, action_result)
self.__logger.info("Result cached for action [%s/%s]",
action_digest.hash, action_digest.size_bytes)
# --- Private API ---
def _get_key(self, action_digest):
return (action_digest.hash, action_digest.size_bytes)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment