Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a3f08d7d
Commit
a3f08d7d
authored
Nov 22, 2019
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a composite, versioned cache key
parent
10d88d8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
lib/gitlab/diff/highlight_cache.rb
lib/gitlab/diff/highlight_cache.rb
+6
-7
spec/lib/gitlab/diff/highlight_cache_spec.rb
spec/lib/gitlab/diff/highlight_cache_spec.rb
+1
-1
No files found.
lib/gitlab/diff/highlight_cache.rb
View file @
a3f08d7d
...
...
@@ -11,7 +11,6 @@ module Gitlab
def
initialize
(
diff_collection
,
backend:
Rails
.
cache
)
@backend
=
backend
@diff_collection
=
diff_collection
@redis_key
=
"highlighted-diff-files:
#{
diffable
.
cache_key
}
"
end
# - Reads from cache
...
...
@@ -58,30 +57,30 @@ module Gitlab
Redis
::
Cache
.
with
do
|
redis
|
redis
.
multi
do
|
multi
|
hash
.
each
do
|
diff_file_id
,
highlighted_diff_lines_hash
|
multi
.
hset
(
@redis_
key
,
diff_file_id
,
highlighted_diff_lines_hash
.
to_json
)
multi
.
hset
(
key
,
diff_file_id
,
highlighted_diff_lines_hash
.
to_json
)
end
# HSETs have to have their expiration date manually updated
#
multi
.
expire
(
@redis_
key
,
EXPIRATION
)
multi
.
expire
(
key
,
EXPIRATION
)
end
end
end
def
read_single_entry_from_redis_hash
(
diff_file_id
)
Redis
::
Cache
.
with
do
|
redis
|
redis
.
hget
(
@redis_
key
,
diff_file_id
)
redis
.
hget
(
key
,
diff_file_id
)
end
end
def
clear
Redis
::
Cache
.
with
do
|
redis
|
redis
.
del
(
@redis_
key
)
redis
.
del
(
key
)
end
end
def
key
@redis_key
[
diffable
.
head_commit_sha
,
VERSION
,
'highlighted-diff-files'
,
diff_options
].
join
(
":"
)
end
private
...
...
@@ -104,7 +103,7 @@ module Gitlab
results
=
[]
Redis
::
Cache
.
with
do
|
redis
|
results
=
redis
.
hmget
(
@redis_
key
,
file_paths
)
results
=
redis
.
hmget
(
key
,
file_paths
)
end
results
.
map!
do
|
result
|
...
...
spec/lib/gitlab/diff/highlight_cache_spec.rb
View file @
a3f08d7d
...
...
@@ -37,7 +37,7 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
new_pos:
20
}]
}
end
let
(
:cache_key
)
{
cache
.
instance_variable_get
(
:@redis_key
)
}
let
(
:cache_key
)
{
cache
.
key
}
subject
(
:cache
)
{
described_class
.
new
(
merge_request
.
diffs
,
backend:
backend
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment