<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert(self, cache_key, paths, overwrite=False):
 """Cache the output of a build. By default, checks cache.has(key) first, only proceeding to create and insert an artifact if it is not already in the cache (though `overwrite` can be used to skip the check and unconditionally insert). :param CacheKey cache_key: A CacheKey object. :param list<str> paths: List of absolute paths to generated dirs/files. These must be under the artifact_root. :param bool overwrite: Skip check for existing, insert even if already in cache. """

    missing_files = [f for f in paths if not os.path.exists(f)]
    if missing_files:
      raise ArtifactCacheError('Tried to cache nonexistent files {0}'.format(missing_files))

    if not overwrite:
      if self.has(cache_key):
        logger.debug('Skipping insert of existing artifact: {0}'.format(cache_key))
        return False

    try:
      self.try_insert(cache_key, paths)
      return True
    except NonfatalArtifactCacheError as e:
      logger.error('Error while writing to artifact cache: {0}'.format(e))
      return False