Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
commit6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch)
treedc4d20fe6064752c0bd323187252c77e0a89144b /lib/gitlab/diff
parent9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff)
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/file_collection/compare.rb4
-rw-r--r--lib/gitlab/diff/highlight_cache.rb29
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/gitlab/diff/file_collection/compare.rb b/lib/gitlab/diff/file_collection/compare.rb
index badebabb192..6d8395d048d 100644
--- a/lib/gitlab/diff/file_collection/compare.rb
+++ b/lib/gitlab/diff/file_collection/compare.rb
@@ -6,9 +6,9 @@ module Gitlab
class Compare < Base
def initialize(compare, project:, diff_options:, diff_refs: nil)
super(compare,
- project: project,
+ project: project,
diff_options: diff_options,
- diff_refs: diff_refs)
+ diff_refs: diff_refs)
end
def unfold_diff_lines(positions)
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb
index 7cfe0086f57..084ce63e36a 100644
--- a/lib/gitlab/diff/highlight_cache.rb
+++ b/lib/gitlab/diff/highlight_cache.rb
@@ -6,7 +6,7 @@ module Gitlab
include Gitlab::Utils::Gzip
include Gitlab::Utils::StrongMemoize
- EXPIRATION = 1.day
+ EXPIRATION = 1.hour
VERSION = 2
delegate :diffable, to: :@diff_collection
@@ -82,6 +82,16 @@ module Gitlab
private
+ def expiration
+ return 1.day unless Feature.enabled?(:highlight_diffs_renewable_expiration, diffable.project)
+
+ if Feature.enabled?(:highlight_diffs_short_renewable_expiration, diffable.project)
+ EXPIRATION
+ else
+ 8.hours
+ end
+ end
+
def set_highlighted_diff_lines(diff_file, content)
diff_file.highlighted_diff_lines = content.map do |line|
Gitlab::Diff::Line.safe_init_from_hash(line)
@@ -125,9 +135,9 @@ module Gitlab
#
def write_to_redis_hash(hash)
Gitlab::Redis::Cache.with do |redis|
- redis.pipelined do
+ redis.pipelined do |pipeline|
hash.each do |diff_file_id, highlighted_diff_lines_hash|
- redis.hset(
+ pipeline.hset(
key,
diff_file_id,
gzip_compress(highlighted_diff_lines_hash.to_json)
@@ -137,8 +147,7 @@ module Gitlab
end
# HSETs have to have their expiration date manually updated
- #
- redis.expire(key, EXPIRATION)
+ pipeline.expire(key, expiration)
end
record_memory_usage(fetch_memory_usage(redis, key))
@@ -188,11 +197,19 @@ module Gitlab
return {} unless file_paths.any?
results = []
+ cache_key = key
+ highlight_diffs_renewable_expiration_enabled = Feature.enabled?(:highlight_diffs_renewable_expiration, diffable.project)
+ expiration_period = expiration
Gitlab::Redis::Cache.with do |redis|
- results = redis.hmget(key, file_paths)
+ redis.pipelined do |pipeline|
+ results = pipeline.hmget(cache_key, file_paths)
+ pipeline.expire(key, expiration_period) if highlight_diffs_renewable_expiration_enabled
+ end
end
+ results = results.value
+
record_hit_ratio(results)
results.map! do |result|