def cache_externally_acquired_bytes()

in ez_wsi_dicomweb/local_dicom_slide_cache.py [0:0]


  def cache_externally_acquired_bytes(self, key: str, data: bytes) -> bool:
    """Adds externally acquired bytes to cache.

    Args:
      key: Cache key for external bytes.
      data: Bytes to add.

    Returns:
      True if data added to cache.
    """
    if (
        self._max_cache_frame_memory_lru_cache_size_bytes is not None
        and len(data) > self._max_cache_frame_memory_lru_cache_size_bytes
        and self.lru_caching_enabled
    ):
      self._get_logger().warning(
          'Data not cached. The maximum size in bytes of the LRU cache is '
          'smaller than the total size in bytes of the data. Data size: '
          f'{len(data)} bytes; Maximum size of cache: '
          f'{self._max_cache_frame_memory_lru_cache_size_bytes}.'
      )
      return False
    self._dicom_instance_frame_bytes[f'ext:{key}'] = data
    return True