lib/gitlab/diff/highlight_cache.rb
# For every file that isn't already contained in the redis hash, store the
#   result of #highlighted_diff_lines, then submit the uncached content
#   to #write_to_redis_hash to submit a single write. This avoids excessive
#   IO generated by N+1's (1 writing for each highlighted line or file).
#
For every file that isn't already contained in the redis hash, store the
result of #highlighted_diff_lines, then submit the uncached content
to #write_to_redis_hash to submit a single write. This avoids excessive
IO generated by N+1's (1 writing for each highlighted line or file).
For every file that isn ' t already contained in the redis hash store the result of #highlighted_diff_lines then submit the uncached content to #write_to_redis_hash to submit a single write . This avoids excessive IO generated by N + 1 ' s ( 1 writing for each highlighted line or file ) .
def write_if_empty
        return if uncached_files.empty?
        new_cache_content = {}
        uncached_files.each do |diff_file|
          next unless cacheable?(diff_file)
          new_cache_content[diff_file.file_path] = diff_file.highlighted_diff_lines.map(&:to_hash)
        end
        write_to_redis_hash(new_cache_content)
      end
def write_if_empty return if uncached_files . empty? new_cache_content = { } uncached_files . each do | diff_file | next unless cacheable? ( diff_file ) new_cache_content [ diff_file . file_path ] = diff_file . highlighted_diff_lines . map ( & :to_hash ) end write_to_redis_hash ( new_cache_content ) end
For every file that isn't already contained in the redis hash, store the
result of #highlighted_diff_lines, then submit the uncached content
to #write_to_redis_hash to submit a single write.
For every file that isn ' t already contained in the redis hash store the result of #highlighted_diff_lines then submit the uncached content to #write_to_redis_hash to submit a single write .